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

[zerolib] Implement `System.Math`

opened this issue · comments

Sooner or later, it still needs to be implemented. It's something very useful to have. It's better to be there than having us to delve into the CRT to be able to use the math functions. It will keep the code compatible with the normal standard library.

@iahung2 out of interest, why have you tagged this as zerolib, but then asked for the math library to be implemented? Isn't zerolib, zero lib?

If you need math routines, why not link to the standard runtime library? Alternatively, couldn't they be ported over selectively?

@iahung2 out of interest, why have you tagged this as zerolib, but then asked for the math library to be implemented? Isn't zerolib, zero lib?

If you need math routines, why not link to the standard runtime library? Alternatively, couldn't they be ported over selectively?

I know zerolib is a minimal runtime. But System.Math is very cheap to implement and is a good addition to have. As I said, I could write Pinvoke code to call the math functions provided by the CRT, but why do I need to do it this way? If there is an implementation of System.Math for zerolib (that I believe will pretty much be a wrapper over the CRT provided math functions), code could be shared between zerolib and the normal standard library. This is my point.

p/s: From what you wrote, it seems you are confusing between --stdlib=none and --stdlib=zerolib. The former is no standard library at all and you need to implement a standard library yourself. The later is a minimal standard library.

@iahung2 Sorry, you are right I was confused and I am using '--stdlib=none'. I've looked through zerolib now and can see what you mean.

What do you think about having a 'clib' option, in addition to zerolib? Even a partial implementation. Just a thought.

What do you think about having a 'clib' option, in addition to zerolib? Even a partial implementation. Just a thought.

I can't image how this clib option looks like. I think you will pretty much reinvent zerolib.

But System.Math is very cheap to implement and is a good addition to have.

Zerolib also works for UEFI boot apps, so an implementation of Math would need to work in completely freestanding mode (no calls into OS since there's no OS). It's not very expensive, but not exactly cheap either if I want the same precision (and I would want it).