DIP69 - Implement scope for escape proof references

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 4 16:50:15 PST 2014


On Thu, Dec 04, 2014 at 04:33:22PM -0800, Walter Bright via Digitalmars-d wrote:
> On 12/4/2014 3:54 PM, H. S. Teoh via Digitalmars-d wrote:
> >>The compiler assumes func(s) returns a ref to s, and so it won't allow
> >>func(s) to be returned from foo().
> >
> >Ah, I see. So you're saying that under this DIP, `return func(...);`
> >from a ref function will be prohibited unless the arguments to func()
> >were all either scope or non-reference?
> 
> Right.
> 
> >That sounds good, though it *is* pretty invasive, as any existing ref
> >functions that do this will need to be revised, which potentially
> >spreads 'scope' to many other places, depending on how deeply the
> >chain of tail recursion / tail func calls go.
> 
> I know:
> 
> 1. that's why the extensive support for scope inference
> 2. I couldn't see any other way

I'm not saying it's necessary a bad thing... just that it will be an
invasive change that we should be prepared to deal with.


T

-- 
English is useful because it is a mess. Since English is a mess, it maps
well onto the problem space, which is also a mess, which we call
reality. Similarly, Perl was designed to be a mess, though in the
nicest of all possible ways. -- Larry Wall


More information about the Digitalmars-d mailing list