[Discussion] VB Runtime Community Extensions
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
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
1. It may be easier to get community involvement writing simple functions that it would be to work on a compiler fork.
2. VB already includes a runtime library (the Microsoft.VisualBasic namespace) that we could use for inspiration as a starting point.
3. Much VB's syntax is very function-like. What do type casts look like? `CType`, `DirectCast`, and `TryCast` look like functions. The ternary conditional expression looks like an `If` function and was probably inspired by the `IIf` function in the runtime library. The null-coalescing operator looks like an "overload" of that same `If` 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?
4. Function calls can be optimized to be just as efficient as built-in operators in many cases. The JIT can inline functions under certain circumstances, and we can add `` to encourage it if we need to. There is also the example of `CInt(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.
5. Originally, my thought would be that, over time, features could migrate from the community extensions to Microsoft.VisualBasic itself (kind of like the relationship between the Windows Community Toolkit and WinUI), but that may not be an option now. If the community does fork the VB compiler though, these extensions could become part of that forked VB implementation.
## Who, What, and How
Those are the big questions:
- Who would be willing to work on this?
- What sorts of functions, classes, etc. would be worth adding to this? (Who is the intended audience for them?)
- How would it be distributed (NuGet, VS extensions, project templates, etc.)? How should it be promoted?
- Could/should we ask for "official" Microsoft assistance on this or should the community go for it on our own?
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.)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.