behavior of this
Jarrett Billingsley
kb3ctd2 at yahoo.com
Wed Jul 25 19:05:55 PDT 2007
"Ender KaShae" <astrothayne at gmail.com> wrote in message
news:f88h4u$31g2$1 at digitalmars.com...
>
> 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
>
Const and invariant methods already exist, though not in the odd "static
with this as first parameter" way that you're proposing.
class A
{
const int foo()
{
// Here I can only call other const/invariant methods
// and can't modify the state of the object
}
invariant int bar()
{
// Similar but even stricter; can only call invariant
// methods and access invariant fields
}
}
More information about the Digitalmars-d
mailing list