In D is it possible to handle accessing class properties that don't exist, similar to PHP's magic methods?

http://www.php.net/manual/en/language.oop5.overloading.php#object.set

For example, the below class doesn't have the 'x' property:

class T
{
    this()
    {
        this.x = "hello world!";
    }
}

Can i handle this in a programmatic way to intercept the property and deal with it?

Something like this:

class T
{
    this()
    {
        this.x = "hello world!";
    }

    opMagic(A, B)(A property, B value)
    {
        // property = "x", value = "hello world!"
    }
}

Reply via email to