3 ms·
> What's wrong with "u8 x = 5;"? I believe it makes the parser marginally more complicated. Let's say you had a non-builtin type, "foo". The var trigger imme
by dnautics 5y ago
> What's wrong with "u8 x = 5;"?
I believe it makes the parser marginally more complicated. Let's say you had a non-builtin type, "foo". The var trigger immediately declares what's going on. For "foo x = 5;" the parser must either 1) have contextual information that foo is a declared type or 2) wait to notice that there are two identifiers side-by-side and then resolve that this means "it must be a variable declaration".
Honestly, C and C++ are very much in the minority for choosing this syntax. Coming form pascal, I remember finding this syntax to be annoying 20 years ago, so it's my bias to believe that this is just internalized pain for C devs.
As for the type coercion with the () operator... well, C is infamous for "spiral types". Typecasting complicated things in C, like, say, an array of pointers, can get scary as hell.
- Someone 5y agoA bit more than marginally more complicated, if you consider the cases of parsing partial or incorrect programs. You want to be able to (somewhat) parse those so that you can syntax-colour, auto-complete, and mark errors in a code editor. I think those are the major reasons modern languages don’t do such things the C way.
- scoutt 5y ago> I believe it makes the parser marginally more complicated This would mean that the "peace of mind" of the Zig compiler developer has priority over my own "peace of mind". That's not ok. Is the compile developer reasoning "I don't care if the syntax is verbose, messy (or whatever), it just makes my job easier"? > Honestly, C and C++ are very much in the minority for choosing this syntax Java, C#, Objective-C....