-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Discussion] VB Runtime Community Extensions #560
Comments
So basically an expanded #231? |
Yes, #231 is something I think should be a part of it. Other things I could see possibly going in:
|
For distribution we could add to VBNetSnippets or fork it if it's no longer maintained. NuGet maybe overkill for unrelated snippets. For promotion we could add a link to Awesome-dotnet and with "official" Microsoft assistance to vblang readme here also. If a proposal here in vblang/issues gets more than 2 rocket smilies this could be a sign to copy this snippet to github. Who is willing to copy the snippets from here to some github or other repository? |
I'm experimenting with a project right now which is a (sort of) forked version of the VisualBasic runtime. I'm frustrated by the fact that I have "full access" to the runtime in .NET 5 WinForms, "limited access" in a .NET 5 Console and "basically none" access in a netstandard2.x library to the runtime. So I started wondering what, exactly, is holding things back. I created a new repo called Community.VisualBasic to explore this. This project isn't really ready for any sort of prime time usage (for example, instead of getting the actual errors when errors occur - most of them will result in "notimplemented" exceptions because the original code was accessing internal resources for these errors... but for my experimenting stage, this isn't an issue). I also changed the namespace as there are issues that I'm not 100% sure how to manage with regards to: a) completely swapping out the runtime with this one... For now my focus has been on netstandard2.0 and netstandard2.1 with some testing taking place in .NET 5 console. Furthermore, for functions that "simply will not work outside of winforms", I've removed these for the time being - after doing so, I realized that they could just be marked as "obsolete" or something. My original thinking was that I'd rather know immediately that something is not going to work instead of being hit with a surprise some sort of platform not working exception during runtime. If you'd like to take a peek and give it a go, please check it out at https://github.com/DualBrain/Community.VisualBasic/ |
In a number of proposals in the last year, a few of us have responded with something along the lines of, "you could write a function to do that". So that's where I'd like to begin, discussing a community-built library of those functions.
Why
CType
,DirectCast
, andTryCast
look like functions. The ternary conditional expression looks like anIf
function and was probably inspired by theIIf
function in the runtime library. The null-coalescing operator looks like an "overload" of that sameIf
function. Array indexing looks like calling functions. In the end, would there be much of a difference between creating a new function and creating a new operator that looks like a function anyway?<MethodImpl(MethodImplOptions.AggressiveInlining)>
to encourage it if we need to. There is also the example ofCInt(Fix(...))
which in recent versions of the VB compiler is reduced to a single IL instruction, and it may be easier to convince the Roslyn team to add more such optimizations than it would be to convince them to add new language features.Who, What, and How
Those are the big questions:
I'm sure there's more that could be added here, but this may be enough to get the discussion started. (And also, whenever someone wants to reply to another language proposal with "you could write a function for that", they could link back here.)
The text was updated successfully, but these errors were encountered: