This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
GOOPS obj representation & arithmetic (Re: Dump float support?)
- To: Marius Vollmer <mvo at zagadka dot ping dot de>
- Subject: GOOPS obj representation & arithmetic (Re: Dump float support?)
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 14 Mar 2000 00:54:52 +0100
- Cc: guile at sourceware dot cygnus dot com
- Cc: djurfeldt at nada dot kth dot se
- References: <E12UWVe-0006CK-00@mdj.nada.kth.se> <87r9dewtvo.fsf@zagadka.ping.de>
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.