behavior of this

Ender KaShae astrothayne at gmail.com
Wed Jul 25 14:59:58 PDT 2007


I think that it would be nice to define how this behave for example:

static func(ref this);

would be called as a.func() which would be equivalent to class.func(a); i.e. this would be a reference to the reference that is calling the function.

or 

static func(invarient this);  would declare that the members of this are constant and can not be changed, if this was implemented then invarient instances of the class should only be able to call methods that have invarient this as a parameter

i'm not sure if this will work but it would be very useful, especially for immutable types.



More information about the Digitalmars-d mailing list