static switch
deadalnix
deadalnix at gmail.com
Wed Mar 5 14:41:02 PST 2014
On Wednesday, 5 March 2014 at 21:54:52 UTC, Timon Gehr wrote:
> On 03/05/2014 07:58 PM, Andrei Alexandrescu wrote:
>> On 3/5/14, 10:45 AM, Dicebot wrote:
>>> On Wednesday, 5 March 2014 at 18:39:08 UTC, Andrei
>>> Alexandrescu wrote:
>>>> Doesn't enable anything. There'd be a ton more juice in a
>>>> static
>>>> foreach; it would enable a lot of great idioms. We should
>>>> pursue that
>>>> instead.
>>>>
>>>> Andrei
>>>
>>> Btw, are there any unexpected design difficulties with static
>>> foreach?
>>> Or it is just waiting for someone to do the pull request?
>>
>> The one difficulty is figuring how to allow for all iterations
>> to stay
>> in the same scope, yet not have duplicate definitions of the
>> iteration
>> symbol.
>
> static if needs exactly the same thing, currently the following
> compiles:
>
> static if(is(int A)){}
> A b; // meh
>
> It's pretty easy to solve: Just give static if/static foreach
> it's own scope, but by default forward symbol insertions to the
> enclosing scope. Symbols introduced by the construct itself are
> inserted directly into its scope and not forwarded.
>
I don't think this is the right solution. Spewing error is better
than overly complicated design.
More information about the Digitalmars-d
mailing list