News for hackers. Stuff that matters.
Re:Ziglings: Learn the Zig programming language by fixing ti... by pron on Sunday February 14, 2021 @07:03AM (#26131659)
I think Zig's comptime has three interesting features:

1. It is referentially transparent, i.e., unlike Lisp, i.e. nothing in the language can distinguish between `1 + 2` and `3`. This means that the semantics of the language is the same as if everything was evaluated at runtime, and the comptime annotation has no impact on semantics (assuming syntax terms aren't objects and there's no `eval`).

2. It supports type introspection and construction.

3. It doesn't have generics and typeclasses as separate constructs but as applications of comptime.

I think 3 is unique to Zig, but I wonder about 1: is it possible in MetaOCaml, as it is in Lisp, C, C++, Rust and Haskell -- but not in Zig! (or, say, Java) -- to write a unit `m`, such that m(1 + 2) is different from m(3)?

Re:Ziglings: Learn the Zig programming language by fixing ti... by ymbeld on Sunday February 14, 2021 @08:27AM (#26132210)
I don’t know. I think MetaOcaml is strict about inspecting Code terms like Code (1 + 2) and Code 3 (as far as I remember it is not allowed). So no, I don’t think you can distinguish between them.