Thread overview
adding static return?
Mar 03, 2014
Xavier Bigand
Mar 03, 2014
Stanislav Blinov
Mar 04, 2014
Nicolas Sicard
March 03, 2014
I thought it could be nice to have a static return.

My Idea is to remove unnecessary bracket encapsulation made with some static if statements.

It will works like this :

module xxx.opengl;

import buildSettings; // contains some global constants

static if (renderMode == directX)
  return;

...


So there will no more need to scope the module code and indent it.

Is it a good idea?
March 03, 2014
I don't get it. That should be a static assert, not static if. Why would you even add into your build order a module that will never be actually compiled?

If anything, static assert will prevent dead imports while such "static return" will silently swallow them.

How would you propose handling module constructors and module-scope variables in presence of such return?
March 04, 2014
On Monday, 3 March 2014 at 23:27:42 UTC, Xavier Bigand wrote:
> I thought it could be nice to have a static return.
>
> My Idea is to remove unnecessary bracket encapsulation made with some static if statements.
>
> It will works like this :
>
> module xxx.opengl;
>
> import buildSettings; // contains some global constants
>
> static if (renderMode == directX)
>   return;
>
> ...
>
>
> So there will no more need to scope the module code and indent it.
>
> Is it a good idea?

This is just to avoid brackets and the compulsion of indenting inside them, isn't it?  ;-)

Version blocks can be used with colons (see http://forum.dlang.org/thread/lep2p3$2765$1@digitalmars.com for a caveat). May be this syntax could be extended to module-level static ifs. D would look more and more like Python...