dotnet / dotnet/vblang

[Proposal] Auto extend shared members and vice versa

Open
#573 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

I usually loose some time trying to use char and string methods as I forget if they are member or shared methods. I also don't know why most of the Char methods are shared not member methods. Why:
`Dim res = Char.IsLetter(c)`
not:
`Dim res = c.IsLetter`
So I am thinking, since we are familiar with extension methods, why can't VB consider each shared method an extension one if it starts with a param of the same class type?
This way the `c.IsLetter` can be lowered to `Char.IsLetter(c)`.
I also suggest the opposite (but it is less important to me): allow to use every member method to be used as a static one:
`Dim x = String.Replace(x, " ", "")`
which can be lowered to:
`Dim x = x.Replace(" ", "")`
Maybe we can make it interesting if we treat the shared form as a byRef Sub:
`String.Replace(x, " ", "")`
So, x is affected in a compact form, as it will be lowered also to:
`x = x.Replace(" ", "")`
Any way, I am interested most in the auto extension part of this suggestion.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.