Is the following code legal?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 2 08:19:40 PDT 2016


On 11/02/2016 11:17 AM, Adam D. Ruppe wrote:
> On Wednesday, 2 November 2016 at 14:21:32 UTC, Shachar Shemesh wrote:
>> The D documentation (https://dlang.org/spec/hash-map.html) leaves this
>> not defined.
>
> The foreach statement is defined to not allow it:
>
> http://dlang.org/spec/statement.html#ForeachStatement
>
> "The aggregate must be loop invariant, meaning that elements to the
> aggregate cannot be added or removed from it in the
> NoScopeNonEmptyStatement."

Yah, we'd do good to relax that to allow removal of the currently 
iterated element. -- Andrei


More information about the Digitalmars-d mailing list