escaping addresses of ref parameters - not

Michel Fortin michel.fortin at michelf.com
Tue Feb 10 03:29:26 PST 2009


On 2009-02-08 22:39:36 -0500, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> ***************
> Rule: ref parameters are PASS-DOWN and RETURN only. No escaping of 
> addresses of ref parameters is allowed. If you want to escape the 
> address of a ref parameter, use a pointer in the first place.
> ***************

Isn't the "this" argument for struct a ref now? So you can't do this 
any longer:

	static A[] listOfRegisteredA;

	struct A
	{
		void register()
		{
			listOfRegisteredA ~= &this;
		}
	}


> This rule is powerful and leads to an honest style of programming: if 
> you plan on escaping some thing's address, you make that clear in the 
> public signature.

But you can't change the "this" parameter to not be a ref, can you?


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list