This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

GOOPS obj representation & arithmetic (Re: Dump float support?)


Marius Vollmer <mvo@zagadka.ping.de> writes:

> Can we have exact rationals instead? ;)

:)

Not instead, but when arithmetic operators are turned into generics...

The idea is this:

1. Integrate GOOPS into libguile

   (Yes, will happen RSN.  I just want to fix some things and make an
   independent release of GOOPS-1.0 first, for those poor souls who
   will be stuck with Guile-1.3.4 for a while.)

2. Replace GOOPS low-level representation
   (structs --> something different)

   Michael Livshin has thought much more than I on this, but something
   like this could be reasonable:

   A GOOPS object is a double-word cell:

   WORD 0: tc7 type tag + 25 GOOPS class flags (used for fast protocols)
   WORD 1: pointer to class data (malloc for class object)
   WORD 2: pointer to data (malloc for object)
   WORD 3: optional; some classes of objects don't need this filled in
           (note that initializing object headers also takes time)

3. Introduce a subclass of <generic> called <arithmetic-generic>.

   Such objects contain 7 pointers to C functions handling the argument
   combinations (), (INUM), (REAL), (INUM, INUM), (REAL, INUM),
   (INUM, REAL) and (REAL, REAL).

   When an <arithmetic-generic> is applied, it first uses simple
   if-statements to dispatch onto one of these "primitive methods".
   If that fails, it behaves as an ordinary generic, i.e., it does
   type dispatch.

4. Turn all standard Guile arithmetic, and comparison operators into
   <arithmetic-generic>s and break up numbers.c into independent
   modules.

After this, we can easily add new types to the numeric tower.  The new
types will be handled a little bit slower than INUMs and REALs, but I
think it will be fast enough.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]