On Tue, 23 Nov 2010 07:59:27 -0500, Lars T. Kyllingstad
<[email protected]> wrote:
If I've understood things correctly, by marking a delegate parameter with
'scope' you tell the compiler not to create a true closure for the
delegate. Effectively you're saying "I promise not to escape this
delegate, so you don't need to copy its context to the heap".
In brief, my question is: Why doesn't the compiler enforce this
promise? In particular, why is 'scope' not a type constructor?
For scope to be a type constructor, D requires some form of
ownership-types & local escape analysis. Just like mutable and immutable
data needs const, I think stack/thread-local/shared data needs scope.
(There is an old proposal on the wiki about the technical implementation,
though it's badly worded) But my understanding is that all things
ownership related are relegated to D3.