4 ms·
What's your source for this? Comptime Zig code can do pointer casts and whatnot, all emulated as if run on the target bitness/endianness/etc. And any operations
by nvme0n1p1 16d ago
What's your source for this? Comptime Zig code can do pointer casts and whatnot, all emulated as if run on the target bitness/endianness/etc. And any operations that are undefined on the target platform result in a compile error. I've never had an issue cross-compiling.
- weinzierl 16d agoEndianness and pointer casts are the mechanical part and I would expect Zig to emulate them correctly. Other parts, like floats are harder. This is where a difference shows. Rust is like: "Sorry, since we cannot uphold our guarantees, no transcendentals for you at comptime ", whereas Zig is chill about that and let you have your transcendentals even if results may differ between comptime and runtime. Different mindsets.
- simonask 16d agoJust to note, Rust has had compile-time floats for a while now, but yes.
- weinzierl 16d agoYes, but no transcendentals on floats. You can add them and the like but you cannot calculate the sine.
- adrian_b 16d agoThe guarantees could be provided, if there would be a way to ensure that the compiler uses the same standard math library that is used by the executable program that is created. This could be done, for instance, if the standard math library would be dynamically linked into the compiler, so the same library would be available for the compiled program.
- weinzierl 16d agoIf you disregard performance, yes. Unfortunately forcing softfloat everywhere would result in abysmal performance, so this is not an option.