4 ms·
Metaprogramming in Zig and parsing CSS
- WalterBright 3y agoHere's a parser generator that uses metaprogramming in D to run it at compile time: https://github.com/PhilippeSigaud/Pegged https://github.com/PhilippeSigaud/Pegged
- generichuman 3y agoIs there one that doesn't depend on libc & the GC?
- WalterBright 3y agoI don't know but here's a selection of them: https://wiki.dlang.org/Lexers_Parsers https://wiki.dlang.org/Lexers_Parsers
- bsaul 3y agofrom all the zig features i've seen, comptime seems like the most likely to have the most impact on future PL design. I don't know how powerful it is in practice, but the idea looks so elegant and simple and they seem to have managed to make it work.
- lionkor 3y agoThe only thing stopping me from using Zig is the lack of docs
- hiccuphippo 3y agoDocs is something they'll probably tackle before version 1.0 after the language is stabilized and they clean up the standard library. Not much sense in writing docs if they are going to need rewriting soon. Right now the best doc is to look at the tests in the code itself.
- motiejus 3y agoThe language docs are OK: https://ziglang.org/documentation/master/ https://ziglang.org/documentation/master/ Zig taught me to read stdlib source, which I do at my $dayjob now too. It is perfectly fine to read stdlib source. Start with lib/std/mem.zig after reading the docs about the language. It is much more readable than the C "docs" ISO/IEC 9899:2011. I am so productive now. :)
- lionkor 3y agoC has cppreference, the standard is not made to be learned from. Zigs stdlib have near zero usable docs. Yes I know you can browse the code, but thats difficult since the zig lsp has very little idea about a lot of types.
- eatonphil 3y agoFor me, I browse through the GitHub UI and I also keep local copies of Zig (for various releases) so I can `git grep` and glance through lib/std/mem.zig or lib/std/array_list.zig or (as in this post) lib/std/json/static.zig. I'm not saying it works for everyone but frankly, like motiejus it sounds, I don't mind the minor challenge of being forced to read source code.
- lenkite 3y agoZig is an amazing language. Just wish they weren't anti-RAII.
- gonzus 3y agoCan you expand on what you mean by anti-RAII?
- eatonphil 3y agoZig lets you explicitly specify `defer` handlers but it doesn't have any way for having implicit/automatic defer handles. So, for example, you can do reference counting in Zig either completely manually or a little less manually with `defer`. But you can't do C++-style smart pointers where you don't need to specify any `defer` and automatically have cleanup run at the end of the block/function.