Cory Spencer <[EMAIL PROTECTED]> wrote: > -> (* 2 3.2) > 9.6 > -> (+ 1.2 3)
> I'm not sure what kind of magic you worked last time with Integers, > Leo, but would you mind working it again? (Or pointing me in the right > direction so that I can fix it myself. :) Short answer: will be fixed soon. The longer story is: The problem is the different memory layout of Integer/LispInteger or Float/LispFloat. As a LispInteger isa(Integer) it inherits all the MMD functions from Integer. These functions used to do: a = PMC_intval(left); # or PMC_num_val for Float b = PMC_intval(right); c = a <op> b; But that doesn't work, if it's a LispInteger / LispFloat. The correct way to go is: a = VTABLE_get_integer(INTERP, left); ... This calls get_integer() implemented in the deleg_pmc.pmc class, which is implicitely a parent of all objects that subclass native PMCs. Some aren't converted (mainly Float). Integer functions mostly call VTABLE_get_integer(). This is the reason that currently you get wrong results for Float operations. Unfortunately calling VTABLE_get_integer twice slows down e.g. "add" by almost 30% which isn't really nice. *But* I'm working currently on some code that should eventually allow the orginal fast access. The plan(tm) is to dynamically install a mmd_wrapper function for such subclassed native types. This wrapper extracts the first attribute (the Integer or Float, ...), calls the MMD function and stores the return result in the object (or creates one) if there is a result. This works already for all the opcodes. Still todo are some more nasty cases with explicit method calls or bound methods that ought to call the wrapper too. > -c leo