Hello Nick,

"BCS" <n...@anon.com> wrote in message
news:a6268ffdcb78cc43db75126...@news.digitalmars.com...

Just jumping a ways down this rabbit hole...

struct S { int i; int opCmp(S s) { return i-- == s.i++; }

{
S a,b,c,d,e; ...
switch(a)
{
case b: break;
case c: break;
case d: break;
case e: break;
}
}
Oh, boy. What the hack does the above do?

It blatantly abuses operator overloading ;)  Start doing stuff like
that, and you'll wind up in wonderland even without changing switch.


Ok then how about:


switch(c)
{
   case getc(): ..... break;
   case getc(): ..... break;
   case getc(): ..... break;
   case getc(): ..... break;
   case getc(): ..... break;
   case getc(): ..... break;
   case getc(): ..... break;
}


Are you only going to allow pure functions and expressions with no side effects? I'd guess you could try and set down the list of rules that makes this sane but it's not something I'd like to try any time soon.


Reply via email to