digitalmars.D - foreach doesn't seem to know about invariant
- Janice Caron (10/10) Nov 22 2007 foreach doesn't seem to know about invariant. Watch...
-
Stewart Gordon
(9/10)
Nov 22 2007
- Ary Borenszweig (2/13) Nov 22 2007 And also: http://d.puremagic.com/issues/show_bug.cgi?id=1615
- Janice Caron (13/13) Nov 22 2007 It'll be interesting to see how we're supposed to overload that with
foreach doesn't seem to know about invariant. Watch... import std.stdio; void main() { string s = "hello"; foreach(ref c;s) { c = '*'; } writefln(s); } Prints *****
Nov 22 2007
"Janice Caron" <caron800 googlemail.com> wrote in message news:mailman.113.1195747061.2338.digitalmars-d puremagic.com...foreach doesn't seem to know about invariant. Watch...<snip> Known bug. http://d.puremagic.com/issues/show_bug.cgi?id=1322 Stewart. -- My e-mail address is valid but not my primary mailbox. Please keep replies on the 'group where everybody may benefit.
Nov 22 2007
Stewart Gordon wrote:"Janice Caron" <caron800 googlemail.com> wrote in message news:mailman.113.1195747061.2338.digitalmars-d puremagic.com...And also: http://d.puremagic.com/issues/show_bug.cgi?id=1615foreach doesn't seem to know about invariant. Watch...<snip> Known bug. http://d.puremagic.com/issues/show_bug.cgi?id=1322 Stewart.
Nov 22 2007
It'll be interesting to see how we're supposed to overload that with opApply, taking const into account, in the next version of const. Do we have to write the function twice? (Four times if you also have to write Value-only versions). const int opApply(int delegate(Key key, Value value) dg) { /* whatever */ } int opApply(int delegate(Key key, ref Value value) dg) { /* whatever */ } I don't think you can say "ref const(Value) value".
Nov 22 2007