[DGD] operator functions for light-weight objects

Felix A. Croes felix at dworkin.nl
Mon Jul 29 00:02:55 CEST 2013


I've implemented C++-style operator functions for light-weight objects.
Example:

    object operator + (object addition)
    {
	/* return this_object() + addition */
    }

which permits the light-weight object with the function above to be used
in an expression like: obj1 + obj2.

Only operators which did not already have a meaning for objects can be
defined in this manner.  Operator functions should always return a new
light-weight object which represents the result.  The sole exception
is operator []=, which represents indexed assignment; this function
should modify the current object and return nothing:

    void operator []= (mixed index, mixed value)
    {
	/* perform this_object()[index] = value */
    }

Further information is given in the commit in the github repository.

Regards,
Felix Croes



More information about the DGD mailing list