Dmitry Olshansky <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #11 from Dmitry Olshansky <> 2012-06-19 
07:40:01 PDT ---
> > auto gen = rndGen;
> > return randomSample(a, 5, gen);
> > 
> > has undefined behavior.
> Code like this is always incorrect, i.e. the problem is more general. I wonder
> whether a compiler can always flag those programs as invalid. Is it possible 
> to
> solve the problem of escaping references to local variables in general?
> If so it should probably be done that way. And a RNG should be made
> non-copyable to force pass by ref.
> If it isn't possible (or inefficient or too time consuming, etc.), then
> std.random should be deprecated and std.random2 should replace it in the long
> run. I believe this is the best solution (but far from perfect) to handle
> design problems like this. I wish there was a better way to fix a wrong design
> decision. But working around (kind of against the language) is not
> future-proof.

I had similar problems with redesign of std.regex. It has few less then ideal
tradeoffs because of that but I've come to appreciate backwards compatibility.

In any case big value types like RNG that seldom get modified but often
forwarded could use ref-counted COW. In D we are thread-local by default and
thus COW is fun and cheap.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to