AltoLang / Alto

Compiler in the works!
MIT License
3 stars 1 forks source link

Allow to embed C# in Alto #80

Open FilipToth opened 2 years ago

FilipToth commented 2 years ago

Background and Motivation

I think it would be beneficial to have the ability to have a C# backend in an Alto application. Or be able to invoke C# functions and import C# DLLs.

API Proposal

We will essentially have to analyze the IL from the DLL when in the Binding stage. These are the steps that we will have to take to analyze the C# Library:

API Usage


#import MyLib

function main() {
    MyCsharpClass.MyCSharpFunction()
}
FilipToth commented 2 years ago

Since we now use the emitter inside the REPL and the compiler itself (#79), this will be much easier. Assign me up!

PS: This will also go hand in hand with (#55), since we need to specify the type the function is a member of. For now, only calling static functions will be allowed since we can't make instances of types. After we're done with #79, we will allow for full instantiation of C# types and function calls.

FilipToth commented 2 years ago

Almost done, will close this when we finish OO support.

FilipToth commented 2 years ago

Upon review, I think we'll hold off on this one for now. Being able to directly embed C# code in Alto seems kind of redundant. Also, thanks to PR #97, we can now invoke static functions from C# Library. Not instantiate types just yet, but that is being worked on.