DIP69 - Implement scope for escape proof references

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 4 10:45:00 PST 2014


On Thu, Dec 04, 2014 at 01:49:06PM +0000, Tobias Pankrath via Digitalmars-d wrote:
> >
> >How would this be handled in the current proposal?
> >
> >class C
> >{
> >  int bar(ref T); // <-- inferred to be scope
> >}
> >
> >class D : C
> >{
> >  override int bar(ref T); // <-- inferred to be NOT scope (but cannot
> >remove scope when overriding)
> >}
> 
> Attribute inference only works for function literals and template
> functions.  So no inference is done for both methods. Template methods
> can not be overwritten.

However, AFAIK, template *classes* trigger attribute inference on its
(non-template) member functions, so this would be problematic:

	class Base(T) {
		T data;
		void method(ref T); // inferred to be scope
	}

	class Derived : Base!int {
		override void method(ref T); // oops, cannot override
	}


T

-- 
I think Debian's doing something wrong, `apt-get install pesticide', doesn't seem to remove the bugs on my system! -- Mike Dresser


More information about the Digitalmars-d mailing list