[DGD] operator functions for light-weight objects

Raymond Jennings shentino at gmail.com
Tue Aug 6 03:51:35 CEST 2013


For the record, experimentation shows that for the [..] operator:

It takes two arguments, the lower and upper bounds of the range.

I.e., obj[x .. y] calls operator [..](x, y)

Absent bounds are shown as nil.



On Sun, Jul 28, 2013 at 3:02 PM, Felix A. Croes <felix at dworkin.nl> wrote:

> 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
> ____________________________________________
> https://mail.dworkin.nl/mailman/listinfo/dgd
>



More information about the DGD mailing list