On 05/31/2011 07:58 PM, Jonathan M Davis wrote:
On 2011-05-31 15:03, Andrei Alexandrescu wrote:
On 5/31/11 4:46 PM, KennyTM~ wrote:
On Jun 1, 11 05:37, Andrej Mitrovic wrote:
If you didn't have fallback, you would probably have to add some kind
of new statement like "goto next" or "fallback" on each of those
cases.

It already exists. It is called#

goto case;

Sigh. Unless it's a recent addition, I didn't know about it, Walter
missed the case during proofreading, and consequently that's not
documented in TDPL.

He probably always uses implicit fallthrough in his own code, and we know that
he doesn't use fallthrough in switch statements as much as he thought that he
did, so I suppose that it's not a great surprise that he miissed it. It would
have been nice to have it in TDPL though.

- Jonathan M Davis

Probably it would be best to take this opportunity to make the language change and then document it in a future edition of the book. With "goto case;" reducing the incremental cost of falling through to near non-existence, I think there is no excuse to keep the current behavior.

Also, I think the runtime error on not handling all cases should be eliminated as well. It's very non-D-ish and error prone in the extreme (as unhandled cases tend to be often rare too). Right there with the HiddenFunc error.

I think improving switch and hidden functions to err during compilation would be right in line with our push to making correct code easy to write and incorrect code difficult to write.


Andrei

Reply via email to