Benjamin Thaut:
Well obviously the std.algorithm sum would also be annoted with
scope. Because it doesn't escape it either. I don't see the
problem here. And in case you really want to escape it, you
need to .dup it.
A additional advantage of my solution is, that the compiler can
prove it to be @safe. Your solution does not allow that.
You can see that the contents of this answer of yours are a
strict subset of the contents of my last post :-)
A problem with that use of "scope" to solve this problem is that
such feature interacts with several other things (like
ownership), so it's a complex topic, so nearly everyone is afraid
of touching and implementing it, so nothing will happen.
This phenomenon has happened even for more contained features the
"old" (prestate) of contract programming, for built-in D tuple
syntax, etc. And we keep having a language with holes, that lacks
such basic features.
This means that sometimes designing a language in a less coherent
way (in Scott Meyers' words) is better than having a language
that lacks certain basic features.
I hope Walter or others will figure out this topic of ownership,
etc.
Bye,
bearophile