At 05:59 PM 11/30/00 +0000, Nicholas Clark wrote:
>On Thu, Nov 30, 2000 at 12:46:26PM -0500, Dan Sugalski wrote:
> > (Moved over to -internals, since it's not really a parser API thing)
> >
> > At 11:06 AM 11/30/00 -0600, Jarkko Hietaniemi wrote:
> > >Presumably.  But why are you then still talking about "the IV slot in
> > >a scalar"...?  I'm slow today.  Show me how
> > >
> > >         $a = 1.2; $b = 3; $c = $a + $b;
> > >
> > >is going to work, what kind of opcodes do you see being used?
> > >(for the purposes of this exercise, you may not assume the optimizer
> > >  doing $c = (1.2+3) behind the curtains :-)
>
>$a=1; $b =3; $c = $a + $b

No, that's naughty--it's much more interesting if the scalars are different 
types.

> > If they don't exist already, then something like:
> >
> >          newscalar       a, num, 1.2
> >          newscalar       b, int, 3
> >          newscalar       c, num, 0
> >          add             t3, a, b
>
>and $c ends up a num?

When the add line is fixed, yup. :)

This is assuming the optimizer can spend enough time and see enough of the 
code to know that we're adding an int and num, so that $c must be a num. If 
not, the newscalar line would be:

         newscalar       c, generic, NULL

to set it to be a generic empty scalar.

>why that line "newscalar c, num, 0" ?
>It looks to me like add needs to be polymorphic and work out the best
>compromise for the type of scalar to create based on the integer/num/
>complex/oddball types of its two operands.

Yup. What add does is based on the types of the two operands. In the more 
odd cases, I assume it's type stuff will be based on the left-hand operand, 
but I wouldn't bet the farm on that yet, as that's a Larry call.

>[Oh. but I'm blinkered in this because I'm attempting to make pp_add in
>perl5 do this sort of thing, so I may be missing a better way of doing it]

vtables make it a lot nicer. Whether they make it faster is still up in the 
air... :)

> > But that probably doesn't help much. Let me throw together something more
> > detailed and we'll see where we go from there.
>
>Hopefully it will cover the above case too.

What, the "what if one of the operands is really bizarre" case?

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to