News for hackers. Stuff that matters.
Re:What Makes the Zig Programming Language Unique? by WalterBright on Thursday October 06, 2022 @02:58AM (#33105276)
Well, D does, too:

    template MakePtrType(T) { alias MakePtrType = T*; }
    MakePtrType!int p;

    pragma(msg, "p is type ", typeof(p));

    dmd -c test2.d

    p is type int*
or perhaps I am misunderstanding you?
Re:What Makes the Zig Programming Language Unique? by FeepingCreature on Thursday October 06, 2022 @06:45AM (#33106678)
To be fair, now we're well out of the realm of CTFE. (Though that edges into the macros debate.)
Re:What Makes the Zig Programming Language Unique? by Jensson on Thursday October 06, 2022 @09:59AM (#33108222)
You aren't returning the new type there, looks like you just inline that code. Zig lets you create and return new types that way while your example looks like just regular template substitution.

Edit: So the main difference seems to be that types are first class citizens in Zig, you can write a normal comptime function that returns a type and either use it to do more metaprogramming or everywhere you would declare a type for a function or variable. I am not aware of any static typed languages that lets you do this with normal language syntax.

C++ does it with templates, but in Zig you can do what C++ templates can but with if statements and loops.

Re:What Makes the Zig Programming Language Unique? by pjmlp on Thursday October 06, 2022 @02:04PM (#33111719)
Just use the Circle compiler and you have the full C++ language at compile time, available today.
Re:What Makes the Zig Programming Language Unique? by WalterBright on Thursday October 06, 2022 @03:05PM (#33112570)
It is returning a new type.

Please show me an example where it differs. D's metaprogramming is very good at constructing types. A member of the D community tried very hard to implement type functions, but it turned out to be redundant with D's existing capability.