http://d.puremagic.com/issues/show_bug.cgi?id=6176


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugd...@yahoo.com.au


--- Comment #7 from Don <clugd...@yahoo.com.au> 2011-07-08 01:03:36 PDT ---
This must be a mistake in TDPL, or just poor wording. It's true that DMD does
relax the rule on compile-time strings, to include global variables which are
initialized in static this(). But it doesn't include _all_ variables.

It's pretty clear that the unqualified description in TDPL ("D allows variables
too") cannot be correct. What if it's a shared variable, for example?

Note that defining it as requiring a compile-time constant allows CTFE to be
used.
If variables are permitted, then the rules become more complicated, not
simpler.

Allowing variables would be an appallingly bad feature. It would mean that to
understand control flow in a function which contains a switch, you need to
check every 'case' statement to see if it's a variable, and then you need to
check if that variable can change from inside the function. 
That's a huge change from the existing language, where you know that the
control expression is the only thing that affects control flow.

This is far worse for code maintenance and readability than 'goto'.

Effectively, this would remove the 'switch' statement from the language. Switch
would become nothing more than syntax salt for a sequence of 'if' statements.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to