If I could travel back in time I'd tell Dennis to make "static" the implicit default, and have a special keyword like "public" or "export" for items that are meant to be accessible from outside the compilation unit.
I'd also ask him to make "switch" break by default.
clang and gcc have a -Wimplicit-fallthrough warning flag that will warn about switch cases that fall through without either C++17's [[fallthrough]] attribute or a /* fallthrough */ comment.
I made Firefox's code base able to compile with -Wimplicit-fallthrough. About one hundred fall through cases needed to be annotated and about 2-3 were actual bugs (though minor).
The only real case I use switch fallthrough for is when you have two cases with the same code, e.g.:
switch (foo) {
case 1:
case 2:
/* common body */
break;
case 3:
/* body 3 */
break;
}
It's not cognitively hard to make an empty case body fallthrough to the next run, but include an implicit break at the end of every nontrivial body.
Supporting Duff's Device is not a compelling feature to support--irreducible loops are basically going to destroy any hope of optimization you might accrue.
Don't forget to tell him to remove (most) implicit conversion and to use a greppable keyword cast(foo) like C++ did instead of "ungreppable" syntax (foo).
That said, I'm more annoyed at C's design commitee to not being able to add new features such as having length-aware arrays in C in the language.
No, even if you could kill Hitler, then WW2 doesn't happen, computers aren't invented yet, so time travel isn't invented yet so you can't head back to kill him. Read your briefing notes.
Comments
If I could travel back in time I'd tell Dennis to make "static" the implicit default, and have a special keyword like "public" or "export" for items that are meant to be accessible from outside the compilation unit.
I'd also ask him to make "switch" break by default.
Then I'd go kill Hitler or something.
But then you would need 'unbreak' or just 'goto' to the next case. No duffs device no cigar.
Probably a module/namespace system would be the biggest improvement.
FWIW: Go's switch statements are break by default, with an explicit 'fallthrough' keyword if one wishes to override that behaviour.
clang and gcc have a -Wimplicit-fallthrough warning flag that will warn about switch cases that fall through without either C++17's [[fallthrough]] attribute or a /* fallthrough */ comment.
I made Firefox's code base able to compile with -Wimplicit-fallthrough. About one hundred fall through cases needed to be annotated and about 2-3 were actual bugs (though minor).
The only real case I use switch fallthrough for is when you have two cases with the same code, e.g.:
It's not cognitively hard to make an empty case body fallthrough to the next run, but include an implicit break at the end of every nontrivial body.Supporting Duff's Device is not a compelling feature to support--irreducible loops are basically going to destroy any hope of optimization you might accrue.
which is probably the case in 90% of all my switch'es. Worst use of a time machine ever.
From Algol's linage point of view, a very good outcome.
Yes, but you would need way fewer of such phrases than you need now. Making the exceptional case take more code is the way to go, IMO.
Many languages also support something like
or even That further decreases the need for falling through.Don't forget to tell him to remove (most) implicit conversion and to use a greppable keyword cast(foo) like C++ did instead of "ungreppable" syntax (foo).
That said, I'm more annoyed at C's design commitee to not being able to add new features such as having length-aware arrays in C in the language.
No, even if you could kill Hitler, then WW2 doesn't happen, computers aren't invented yet, so time travel isn't invented yet so you can't head back to kill him. Read your briefing notes.
Also https://tvtropes.org/pmwiki/pmwiki.php/Main/HitlersTimeTrave...
"Locating a lone, disillusioned war veteran wandering around post-WWI Europe is perhaps the ultimate needle-in-a-haystack search"
A time traveler shouldn't have a limit on time to search, so this doesn't make sense as an objection to me.
Apparently everyone kills Hitler on their first trip [1].
[1] https://www.tor.com/2011/08/31/wikihistory/
Because, admittedly, non-default switch breaks are on par with Hitler