On Saturday, 3 August 2013 at 18:51:24 UTC, MattCoder wrote:
On Saturday, 3 August 2013 at 18:04:03 UTC, Walter Bright wrote:
On 8/3/2013 10:45 AM, w0rp wrote:
I can see you saving a little bit of typing with this, but
it's
not worth it.
It would be a very unconventional syntactic form, and my
experience with such things is it'll see very, very little use.
I would like to use this topic and ask if it would be possible
to extend a feature of D language like in this case related by
the author.
Imagine that a user want to put a trigger when "switch
statement" match some option, wouldn't be nice if D could do
something like this:
switch(x){
onBeforeMatch = callFoo();
case n1:
...
case n2:
...
}
Where onBeforeMatch could be onAfterMatch.
Matheus.
You can accomplish the exact same and more with my suggestion.
switch (x)
{
common: callFooBefore();
case n1: break;
case n2: break;
default: break;
common: callFooAfter();
} else { }
This should be the standard template for switch statements... why
we must not progress out of the 80's is beyond me...
What I really don't get it is why people think that just because
they won't use such a feature then it must be useless to everyone
else.