Bug 16659 – Clarify mutating while iterating rules

Status
ASSIGNED
Severity
enhancement
Priority
P4
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-11-03T08:03:17Z
Last change time
2024-12-15T15:23:58Z
Keywords
pull
Assigned to
Seb
Creator
Shachar Shemesh
Moved to GitHub: dlang.org#4062 →

Comments

Comment #0 by shachar — 2016-11-03T08:03:17Z
Consider the following program: int[int] hash; .. foreach( key, ref value; hash ) { if( value>12 ) hash.remove(key); } There is no reference in https://dlang.org/spec/hash-map.html whether this is legal or not (i.e. - removing an element from the hash while iterating it). According to http://dlang.org/spec/statement.html#ForeachStatement, this seems forbidden (in which case it needs to be documented in the first link), but a forum discussion seemed to gravitate toward needing to allow this (as C++ does, at least since C++14).
Comment #1 by andrei — 2016-11-03T12:33:41Z
Alex, I'm passing this to you since you've already looked at AAs a bit.
Comment #2 by andrei — 2016-11-03T12:38:24Z
Comment #3 by greensunny12 — 2017-06-15T06:06:50Z
Comment #4 by robert.schadek — 2024-12-15T15:23:58Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dlang.org/issues/4062 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB