News for hackers. Stuff that matters.
Re:Zig 0.12.0 Release Notes by throwawaymaths on Monday April 22, 2024 @01:47PM (#40116779)
That's actually a problem. In c, variable declarations are not context-free.

    mytype *foo;
Could be a variable declaration, Or is it?

Suppose you had

    int mytype = 42;
    int foo = 1;
Before it. The C compiler will happily turn the statement into a multiplication with the result going to /dev/null

    var foo: mytype;
Can never be parsed with any other meaning depending on how the chips fall after parsing (and possibly analysis, given that macros are a thing) the entirety of the file.
Re:Zig 0.12.0 Release Notes by jstimpfle on Monday April 22, 2024 @02:17PM (#40117106)
Yes it comes with its problems. The context sensitivity is annoying and it makes creating good tooling hard. But given macros it doesn't worsen the situation much anyway.

For writing a batch parser/compiler that properly reads all the includes too, the context sensitivity is only a theoretical problem. Adding a type table is easy.

Not having to type "var" all the time is very nice on the other hand.

Re:Zig 0.12.0 Release Notes by throwawaymaths on Monday April 22, 2024 @10:16PM (#40127767)
Clarity is always better than saving keystrokes. Code is generally more read than written.
Re:Zig 0.12.0 Release Notes by jstimpfle on Tuesday April 23, 2024 @04:02AM (#40129619)
Adding keystrokes is not the same as adding clarity, though.