3 ms·
> type Example = Something[Example] You can't use the binding early like this, but inside of the type definition you can use the @This() builtin to get a value
by anonymoushn 2y ago
> type Example = Something[Example]
You can't use the binding early like this, but inside of the type definition you can use the @This() builtin to get a value that's the type you're in, and you can presumably do whatever you like with it.
The type system barely does anything, so it's not very interesting when type checking runs. comptime code is type checked and executed. Normal code is typechecked and not executed.
comptime is not a macro system. It doesn't have the ability to be unhygienic. It can cleverly monomorphize code, or it can unroll code, or it can omit code, but I don't think it can generate code.
- shakna 2y agoUntil version 0.12.0 (April 2024), you could make arbitrary syscalls, allowing you to generate code at comptime, and promote vars between comptime and runtime. [0] Before then, you could do some rather funky things with pointers and memory, and was very much not hygienic. [0] https://ziglang.org/download/0.12.0/release-notes.html#Comptime-Memory-Changes https://ziglang.org/download/0.12.0/release-notes.html#Compt...