Divide & Conquer divides, but doesn't conquer
Timon Gehr
timon.gehr at gmx.ch
Mon May 25 17:34:36 UTC 2020
On 25.05.20 19:25, Stefan Koch wrote:
> On Monday, 25 May 2020 at 17:23:50 UTC, Timon Gehr wrote:
>> On 25.05.20 19:21, Stefan Koch wrote:
>>> On Monday, 25 May 2020 at 17:16:12 UTC, Timon Gehr wrote:
>>>> On 25.05.20 18:57, Stefan Koch wrote:
>>>>> On Monday, 25 May 2020 at 16:46:16 UTC, Timon Gehr wrote:
>>>>>> [...]
>>>>>
>>>>> What do you do about the scopes?
>>>>
>>>> Nothing special. Why would I have to?
>>>
>>> You need a manifest constant for you IV (induction variable), no?
>>> Which would clash with the one previously introduced.
>>>
>>
>> Sure, so I create one forwarding scope per iteration. This is not
>> particularly expensive, it's constant overhead per iteration.
>
> Since Forwarding scopes where not in the language before you introduced
> static if.
> Could you give a quick explanation how they work?
>
It's a scope that forwards new symbols to its parent scope on insertion.
This way, each iteration of the `static foreach` will have its own local
scope with distinct loop variables, but any declarations that are
generated in the `static foreach` body will skip this scope and instead
populate the parent scope. (As an experiment, the original
implementation also had `__local` declarations to insert symbols into
the local scope without forwarding.)
More information about the Digitalmars-d
mailing list