static try catch construct would be helpful

Koroskin Denis 2korden+dmd at gmail.com
Wed Mar 26 08:23:58 PDT 2008


On Wed, 26 Mar 2008 18:14:18 +0300, Janice Caron <caron800 at googlemail.com>  
wrote:

> Useful though static try/catch would be, I'd like to see static
> switch/case, static for, static while, and static foreach first.


Or just "static" keyword:

static {
    switch (i) {
        case 1: doSomeThing();
        case 2: doSomeThingElse();
    }
}

static assert(value);        <=>         static {
                                               assert(value);
                                          }

static if (condition) {                  static {
     /* ... */                <=>              if (condition) {
                                                   /* ... */
                                               }
                                          }
}

Just like debug:

debug writefln("%s", value);    <=>     debug {
                                              writefln("%s", value);
                                         }

Fits nicely! :)
(Hope, you use fixed-width fonts)



More information about the Digitalmars-d mailing list