4 ms·
I never got used to having variables sandwiched inside a type. I know I am not supposed to suggest out-of-the-box, but why can't we add a new syntax, e.g.:
by hzhou321 10y ago
I never got used to having variables sandwiched inside a type. I know I am not supposed to suggest out-of-the-box, but why can't we add a new syntax, e.g.:
return_type Fn(parameters) var;
typedef return_type Fn(parameters) TypeName;
where Fn is a new keyword -- or not, if compiler understands dummy syntax -- (I would suggest λ when using greek letters in code become norm).
It simplifies the C syntax a lot IMHO.
PS: now I am out-of-the-box, maybe this is better:
Fn{return_type, param1, param2} *var;
- eridius 10y agoYou'd have to call it something like `_Fn` instead, or you're going to conflict with existing code (the C standard reserves identifiers starting with an underscore followed by a capital letter; it also reserves identifiers starting with two underscores, but it's fairly common for code to ignore that and use identifiers like that anyway).
- pwdisswordfish 10y agoIIRC the former is basically what D does. The keyword is `function`.
- hzhou321 10y agoAnother thorn in the C syntax is to allow a single statement following if, for, while, etc.. How many pitfalls, walk-around have we struggled with because of it? Just put the braces into the statement syntax please.