3 ms·
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
by throwawaymaths 3y ago
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.
- jstimpfle 3y agoYes 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.
- throwawaymaths 3y agoClarity is always better than saving keystrokes. Code is generally more read than written.
- jstimpfle 3y agoAdding keystrokes is not the same as adding clarity, though.