local enum

Seb seb at wilzba.ch
Sun Jul 8 19:06:23 UTC 2018


On Sunday, 8 July 2018 at 18:45:48 UTC, Mr.Bingo wrote:
> On Sunday, 8 July 2018 at 11:29:23 UTC, Seb wrote:
>> On Saturday, 7 July 2018 at 18:48:35 UTC, Mr.Bingo wrote:
>>> static foreach and enum do not play nice together!
>>>
>>> import std.meta, std.stdio;
>>> import std.string : leftJustify, center, rightJustify;
>>> alias functions = staticMap!(ApplyRight!(Instantiate, string),
>>>                              leftJustify, center, 
>>> rightJustify);
>>>
>>> [...]
>>
>> __local has actually been suggested and implemented as part of 
>> DIP 1010. IIRC it was removed because A&W wanted to see how 
>> static foreach plays out.
>>
>> https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1010.md
>
> Interesting. A lot of goodies in that Dip! I guess we won't get 
> any crackers though?

As mentioned Timon already has an implementation for the goodies.
At the review of the DIP, it was agreed to only merge the basic 
set of the DIP to gain more experience with it before adding more 
complexity.
However, imho it became clear that static break and __local would 
be very useful. While there are hacks around it (you already 
mentioned the mixin trick and there's a similar one for static 
break: define a dummy symbol when you want to break out and check 
for its existence with typeof in an overall static if, the 
proposed syntax would be much more concise and readable. It just 
requires someone to step up and submit a follow-up DIP.


More information about the Digitalmars-d mailing list