5 ms·
I think F# could do this well.
by quonn 4y ago
I think F# could do this well.
- Koshkin 4y ago.NET can do it: https://learn.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/dynamic-source-code-generation-and-compilation https://learn.microsoft.com/en-us/dotnet/framework/reflectio...
- bob1029 4y agoSee also - Source Generators, which can replace some forms of reflection. https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/source-generators-overview https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/s...
- int_19h 4y agoA big reason why this kind of stuff doesn't quickly become unreadable in C# is that the output of a source generator must be a new file. So the ability to extend existing code is limited to the facilities that the language specifically provides for this purpose (partial classes & members, extension methods etc). It also means that tooling can treat all such generated code as virtual files, allowing them to be inspected, debugged etc.
- quonn 4y agoI meant this which is different: https://learn.microsoft.com/en-us/dotnet/fsharp/tutorials/type-providers/ https://learn.microsoft.com/en-us/dotnet/fsharp/tutorials/ty... For example, there is an SQL provider that gives you generated types and auto-complete but it does this without running a source generator that emits files. It just happens inside the compiler.