reasoning of evaluating code after return in current block (static if return)

bastien penavayre via Digitalmars-d digitalmars-d at puremagic.com
Sun May 7 16:41:00 PDT 2017


On Sunday, 7 May 2017 at 23:20:26 UTC, Adam D. Ruppe wrote:
>
> I would just write it `else static if` all on one line and not 
> indent further. Then it barely looks any different anyway.

I just realized that I accidentally posted this while editing.
I agree with you on that this is barely different from just 
adding "else".

The example that I wanted to put was the following.

{
     enum index = ...;
     static if (I >= args.length)
        return ...; //uses index
     else
     {
        enum result = ...;
        static if (!result[0])
        {
           static if (name.length == 0)
              return ...;
           else static if (result[2] >= txt.length)
              return ...;
           else
              return ...;
        }
        else
        {
           enum next = ...;
           static if (!next[0])
              return ...;
           else
           {
              ...
              return ...;
           }
        }
    }
}


More information about the Digitalmars-d mailing list