3 ms·
So it's more like a C transpiler than a dialect of C IMO (it effectively looks more Rust-like than C-like). I'm not just saying that for nitpicking the obviousl
by simias 7y ago
So it's more like a C transpiler than a dialect of C IMO (it effectively looks more Rust-like than C-like). I'm not just saying that for nitpicking the obviously vague definition of "dialect" but rather because it's a very important feature IMO, and actually makes this project potentially more useful to me.
I'd be very wary of switching my toolchain to an experimental one in production, especially if I'm targeting some niche DSP. On the other hand generating C and then compiling it as usual seems less of a hurdle to me. They actually point that out in the intro but I thought it might be worth mentioning it here.
Now I just quickly skimmed the readme but do they explain how they deal with interfacing with standard, non-ZZ C code? I assume they need some sort of "FFI" bindings like Rust to make the code safe.
- speps 7y agoI think I found some FFI examples: - Using ZZ struct in C: https://github.com/aep/zz/tree/master/tests/mustpass/inlineincludedeps/src https://github.com/aep/zz/tree/master/tests/mustpass/inlinei... - Using C code in ZZ: https://github.com/aep/zz/tree/master/tests/mustpass/ctype_in_decl/src https://github.com/aep/zz/tree/master/tests/mustpass/ctype_i...
- rezeroed 7y agoIt will always emit C into a C compiler which will then emit the binary. Presumably we can dump the C before compilation?
- iainmerrick 7y agoWhy? For this purpose, C is a very convenient and very portable assembly language. You could use a verified C compiler like CompCert to convert it to machine code. In an ideal world, there’d be no C compiler in the loop at all, sure. But in practice it’s not causing any trouble at all in a ZZ -> C -> machine code workflow. Quite the reverse, targeting C has some major benefits. (There are C compilers that are very fast, very highly optimizing, very portable, and/or verifiably correct.) Edit to add: just realised I might have totally misunderstood your comment, sorry! Apologies for jumping the gun if so. If you just mean can we save the generated C to disk instead of compiling it, yes, I would hope so too.
- a3p 7y agoAbsolutely! The zz export command just dumps the C and SMT code along with makefiles for common build systems and stops there. Very handy for using it within other toolchains.