Draco-lang / Language-suggestions

Collecting ideas for a new .NET language that could replace C#
75 stars 5 forks source link

Importing native dlls out of the box #70

Open Binto86 opened 2 years ago

Binto86 commented 2 years ago

In c# to use functions from native dll you need to create new function in c# and mark it with dllimport attribute. It would be nice to be able to use native functions without any of this code. Because Fresh supports free functions, this should be much more doable than in c# where you need class for everything.

Edit: (I am editing this long time after I created this issue and we have now much better idea how the language should look) This could probably be done using macros, syntax could be import_native!("user32.dll") and the signature information would be read from the .h file

svick commented 2 years ago

How would that work? As I understand it, native DLLs generally don't expose signatures of the exported symbols.

LPeter1997 commented 2 years ago

As @svick mentioned, this is impossible without symbolic information, which is usually not present in native DLLs.