bflattened / bflat

C# as you know it but with Go-inspired tooling (small, selfcontained, and native executables)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Which language features not available in the Zero stdlib?

opened this issue · comments

I'm interested in this stdlib. But the only thing I know is it doesn't have a GC. The thread asking about memory management #138 is too few in the details. The answer by Dwedit is to use HeapAlloc/HeapFree on raw pointers. But, how?

Btw, I did a quick Google search. HeapAlloc/HeapFree are Windows-only. What if I want to develop for Linux? Or, what if I want to do it in a cross platform way so it will work everywhere?

Please elaborate. Thank you.

Implementation of zerolib is here: https://github.com/bflattened/bflat/tree/master/src/zerolib

It's the best docs. Sorry, I don't have time to write better docs for this.

You can p/invoke into libc (use malloc/free, for example). These APIs are pretty universal and available on both Linux and Windows.

You can p/invoke into libc (use malloc/free, for example). These APIs are pretty universal and available on both Linux and Windows.

Is there a ready to use definition or I have to write the p/invoke definition myself? For example, I found both HeapAlloc/HeapFree in WindowsAPIs.txt. Where is the C# definition for them? Or, do I need to write the p/invoke definition myself?

You have to write it yourself (or google for it, or ask github copilot to write them for you).

From the table on https://flattened.net/, the Zero stdlib only has Marshalling-less p/invoke. Could you elaborate more about this? How could I handle the struct layout and the fixed size C string members in the struct?

Do I need to write the p/invoke definition myself to use the functions in WindowsAPIs.txt? Or is there something ready to use?

You have to write it yourself.

Console.Write can only write a single character? I tried to write an integer and it failed to compile. Only Console.WriteLine support writing a string and has an overload to write an integer.

zerolib has just the code needed to make the examples run. If you need anything else, you have to write it yourself. If you have questions on what is implemented and what isn't, you can look at the code. Either it is there or not (most likely not).

zerolib has just the code needed to make the examples run. If you need anything else, you have to write it yourself. If you have questions on what is implemented and what isn't, you can look at the code. Either it is there or not (most likely not).

Can I ask for more methods of the standard runtime to be added to zerolib? Writing these methods myself is not an option.

@MichalStrehovsky is the owner and decide everything. I am just a passerby trying to help a fellow user :-)

My own take is that zerolib is an experiment/gift from Michal for people who want to play around, try out new things and are willing to tolerate rough edges. I don't think there are any plans to make zerolib anything more than that, but Michal can correct me if I am wrong.

Implementation of zerolib is here: https://github.com/bflattened/bflat/tree/master/src/zerolib

It's the best docs. Sorry, I don't have time to write better docs for this.

I'm certainly not asking you to do this @MichalStrehovsky, but in my own travels with bflat I might investigate extending it to link to other 'standard libraries'. I'm currently planning to use the none compile option, but link to my own ported clib (not decided which one).