Re: Safe Usage of Mutable Ranges in foreach scopes

2015-05-09 Thread via Digitalmars-d-learn
On Friday, 8 May 2015 at 11:25:26 UTC, Per Nordlöw wrote: Could the scope keyword be used here? Could the work done in DIP-25 be reused here, Walter? I had `scope!(const ...)` in my original proposal [1] to handle exactly this problem. The latest iteration doesn't have it as an explicit

Re: Safe Usage of Mutable Ranges in foreach scopes

2015-05-08 Thread via Digitalmars-d-learn
On Friday, 8 May 2015 at 11:32:50 UTC, Per Nordlöw wrote: On Friday, 8 May 2015 at 11:29:53 UTC, Per Nordlöw wrote: Such a feature would make the usage of this pattern very (perhaps even absolutely) safe from a memory corruption point of view. An alternative non-restrictive (relaxed)

Re: Safe Usage of Mutable Ranges in foreach scopes

2015-05-08 Thread via Digitalmars-d-learn
On Friday, 8 May 2015 at 11:29:53 UTC, Per Nordlöw wrote: Such a feature would make the usage of this pattern very (perhaps even absolutely) safe from a memory corruption point of view. I guess I should have posted this on digitalmars.D instead ...

Safe Usage of Mutable Ranges in foreach scopes

2015-05-08 Thread via Digitalmars-d-learn
I use a lot of file parsing looking like alias T = double; T[] values; foreach (line; File(path).byLine) { foreach (part; line.splitter(separator)) { values ~= part.to!T; } } The key D thing here is that this is _both_ fast (because no copying of file-memory-slices needs

Re: Safe Usage of Mutable Ranges in foreach scopes

2015-05-08 Thread via Digitalmars-d-learn
On Friday, 8 May 2015 at 11:25:26 UTC, Per Nordlöw wrote: Such a feature would make the usage of this pattern very (perhaps even absolutely) safe from a memory corruption point of view. Correction: Not exactly memory corruption point of view. Rather to avoid logical bugs when