How to complex switch?

Timon Gehr timon.gehr at gmx.ch
Thu May 12 09:07:42 PDT 2011


Note that it would in principle be possible to have a library-based solution that
provides the functionality you want with the following syntax:

import rswitch; // I made that module name up.
...
mixin(rswitch(q{
switch(str){
  case "abc", "def", "as+b?":
    if( str == xxxx || str == yyyy && etc...)
       s1();
    }
    break;

  case "za+", "wd?", "aaa":
    s2();
    break;

   default: s3();
}
}));

AST macros will eventually make this look even prettier but I think that will not
be too soon.

Timon



> Hi Dennis,
>
> From what I can see u did not provide any clear answer and hence,
> I would only discount all your threads as hostile to someone new to
> D-Programming that is asking sincere and providing some clearly supportable
> features. If those feature are as what u have rapidly
> shot down. Then, may I ask, why the builder of bash and other similar
> script level language supports.
>
> From what I can see D is trying to bridge the gap of API level programming
> language and Scripting Language like Ruby and others.
>
> The point of success in any large scale and long term development
> cycle in shown clearly in the industry is to make things easy and
> approachable.
>
> And not to take a Guru(ONLY I know best) approach?? Mind you, you
> are not omnipotent.
>
> I am not too sure if you work for digitalmars. But I hope not, because
> that is what is being shown here.
>
> http://www.digitalmars.com/d/
> -----------------------------------------------------
> Notice: We >welcome feedback< about the D compiler or language, but please be
> explicit about any claims to intellectual property rights with a copyright or
> patent notice if you have such for your contributions.
>


More information about the Digitalmars-d mailing list