At 04:05 PM 11/30/00 -0500, Chaim Frenkel wrote:
> >>>>> "DS" == Dan Sugalski <[EMAIL PROTECTED]> writes:
>
> >> The "add" op would, in C code, do something like:
> >>
> >> void add() {
> >> P6Scaler *addend;
> >> P6Scaler *adder;
> >>
> >> addend = pop();  adder = pop();
> >> push addend->vtable->add(addend, adder);
> >> }
> >>
> >> it would be up to the addend->vtable->add() to figure out how to do the
> >> actual addition, and what type to return.
>
>DS> Yup. I think it'll be a little more complex than that in the call,
>DS> something like:
>
>addend-> vtable->(add[typeof adder])(adder);
>
>DS> The extra level of indirection may hurt in the general case, but I think
>DS> it's a win to call the "add an int scalar to me" function rather than 
>have
>DS> a generic "add this scalar to me" function that figures out the type 
>of the
>DS> scalar passed and then Does The Right Thing. I hope. (Yeah, I'm betting
>DS> that the extra indirect will be cheaper than the extra code. But I'm not
>DS> writing that in stone until we can do some benchmarking)
>
>Is all that really necessary? Why not a non-vtbl function that knows how
>to add numeric types?

Which numeric types? Int? BigInt? Num? BigNum? Complex numbers? One of the 
reasons to go with the vtable stuff is to allow for smaller, targeted 
routines. More code overall, but less that needs to be dealt with at any 
one time. (More specifically, more of the code for each function that gets 
loaded into the cache gets used)

>I would have wanted to limit the vtbl to self manipulation functions.
>Set, get, convert, etc. Cross object operations would/should be
>outside the realm of the object. (It seems like trying to lift yourself
>by the bootstraps.)

No, a lot of the cross-scalar manipulations can be handled this way as long 
as you provide for an "other" slot for any scalar that doesn't fall within 
the realm of things we have specific routines for.

                                        Dan

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

Reply via email to