goodpaul6 / Tiny

A very small statically-typed embeddable scripting language.
MIT License
246 stars 16 forks source link

Tiny should let size of int and float be user definable #18

Open jockm opened 4 months ago

jockm commented 4 months ago

I started to go down the path of defining tiny_int_t and tiny_float_t so someone embedding Tiny could change these if need be -- for example I need to ensure 64 bit ints in the environment I wanted to embed Tiny in. It would be very easy to imagine a case where someone wants double precision floating point in their app.

Unfortunately it wasn't quite as simple as replacing all the uses of int and float with tiny_int_t and tiny_float_t because I saw instances of the code assuming ints were 4 bytes long and just using the constant 4 instead of sizeof(...). And decided to stop my effort.

I think this is a good idea and should be done.

goodpaul6 commented 1 month ago

@jockm Interesting thought. I don't think it should be too bad to just go through the codebase and replace places where I hardcoded 4 with sizeof/alignof. Thanks for bringing this up.

goodpaul6 commented 3 weeks ago

@jockm Working on this now :) Will have a PR up soon and would appreciate if you could review it to see if it resolves the problem for your use case.