On Thu, Dec 07, 2000 at 01:14:40PM +0000, David Mitchell wrote:
> Dan Sugalski <[EMAIL PROTECTED]> wrote:

> > All the math is easy if the scalars are of known types. Addition and 
> > multiplication are easy if only one of the scalars involved is of known 
> > type. Math with both of unknown type, or subtraction and division with the 
> > right-hand operand of unknown type, is rather more difficult. :(
> 
> I'm not clear with your scheme how addition works if one of the scalars
> (the adder) is of unknown type. ie
> 
> given sv1 of type NUM, sv2 of type UNKNOWN; $sv1 + $sv2 would invoke:
> 
> sv1->add[UNKNOWN](sv2),
> 
> which somewhere will cause a function in the vtable for NUMs to be called, eg
> 
> NUM_add_UNKNOWN(sv1,sv2) { .... }
> Now, how does does this function perform its calculation?

I'm guessing that Dan is planning to take advantage of addition and
multiplication being commutative.

sv1->add[UNKNOWN](sv2)

swaps to 

sv2->add[NUM](sv1)

(It's "obvious" in the usual way - not obvious until you see it. I've been
prodding in pp_add in perl5, so I've been thinking about these sort of
things)

Nicholas Clark

Reply via email to