Why is 'scope' so weak?
Robert Jacques
sandford at jhu.edu
Tue Nov 23 20:26:54 PST 2010
On Tue, 23 Nov 2010 07:59:27 -0500, Lars T. Kyllingstad
<public at kyllingen.nospamnet> 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.
More information about the Digitalmars-d
mailing list