bearophile wrote: > This discussion clearly shows that the current semantics of the "auto" is > not clean enough and it needs to be improved. To improve it D needs to > adopt the strategy of using all attributes in a more tidy and semantically > clean way, as Java does. Java doesn't compile "useless" or wrong > attributes as D sometimes does. > > So it can be better to this to be a compilation error: > enum x = 10; > And accept only: > auto enum x = 10; > Or: > int enum x = 10; > > Such tidy enforcement of attributes can be seen as fussy and sometimes it > requires extra compilations to remove all the mistakes, but it helps the > programmer understand in less time the semantics of those attributes. In > pedagogy it's well known that when a student is learning something, it's > much better if the rules are enforced in a strict way at the beginning. > > And I'd like in D2 the "override" to be always necessary (even when the > code is not compiled with "-w") as in C#, to avoid other bugs. I can show > an example of such possible bugs. > > Bye, > bearophile
Indeed. It was bad when C defaulted functions and variables to int if you didn't specify the return type or type respectively. C++ was smart to make that illegal. All it does is invite errors. Saving those few keystrokes isn't worth the added cost in clarity and potential bugs. As for override, I second, third, and fourth that. I don't know why it wasn't that way in the first place. Override was a very addition by the C# guys and it's a lot more effective if it's required. Like not requiring a type (or auto), not requiring it (and not allowing it when it isn't applicable) invites confusion and errors. I'm all for requiring it. - Jonathan M Davis
