Bill Hart wrote:
> Is there a way to define left operators, i.e. suppose you have defined a
> class C and you want to define a multiplication operator for C which
> handles the expression
>
> a * c
>
> where a is an int say, and c is of type C?
Yes, "oper <binop>" has an "r" modifier:
class X { X oper r+(int i) { return this } }
X x = {}; import
crack.io cout; cout `$(100 + x)\n`;
We actually refer to this as "right" multiplication, though, referring to the
location of "this" in the expression (and copying python's __rmul__, __radd__
...)
>
> I can currently only work out how to define right multiplication, and left
> multiplication does not appear to be rewritten as right multiplication (of
> course you wouldn't want this for subtraction anyway).
>
> Bill.
>
> --
> You received this message because you are subscribed to the Google Groups "crack-lang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
crack-lang-de...@googlegroups.com.
> For more options, visit
https://groups.google.com/groups/opt_out.
>
=============================================================================
michaelMuller =
mmu...@enduden.com |
http://www.mindhog.net/~mmuller
-----------------------------------------------------------------------------
We are explorers in the further reaches of experience: demons to some, angels
to others. - "Pinhead" from "Hellraiser"
=============================================================================