This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: After GOOPS integration: Computation with native types!
- To: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Subject: Re: After GOOPS integration: Computation with native types!
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 15 Aug 2000 12:39:19 +0200
- Cc: djurfeldt at nada dot kth dot se, guile at sourceware dot cygnus dot com, rms at gnu dot org, gang-of-four at red-bean dot com, Keisuke Nishida <kxn30 at po dot cwru dot edu>
- Cc: djurfeldt at nada dot kth dot se
- References: <Pine.LNX.4.21.0008151157000.19390-100000@marvin.ida.ing.tu-bs.de>
- Reply-To: djurfeldt at nada dot kth dot se
Dirk Herrmann <dirk@ida.ing.tu-bs.de> writes:
> On 15 Aug 2000, Mikael Djurfeldt wrote:
>
> > Assume that if FOO is given two <fixnum>s, it is
> > guaranteed to return a <fixnum> (example: a binary `-').
>
> Well, binary '-' might also return a bignum :-)
Sorry, that was really stupid.
But I have another document where I describe how these kinds of cases
can be handled. I thought it best to show a simple case first, but
alas.
> > I propose that we instead give each Guile primitive a type signature,
> > and that argument checking and conversions are made outside of the
> > code of the primitive.
>
> This is a great idea. We should be aware, however, that there are
> probably certain types that can not be given a simple signature, for
> example an alist.
In such a case, we use <pair> in the signature. (The <null> case is a
different primitive.)
> Thus, type signatures would probably only be feasible for 'atomic'
> types, which means that some remaining tests would still have to be
> performed within the primitives.
Yes.
> Thus, while this idea can probably be applied to a large set of
> guile's current primitives (especially to the vast majority of
> functions in numbers.c), we should try to have a hybrid approach,
Yes.
> (- <fixnum> <fixnum>) delivers a fixnum or a bignum. (Well, thinking of
> it, you might compile the continuation of the '-' into two separate
> functions, which are then called depending on the resulting type :-)
:-)
*Exactly*
And the continuation is simply a generic function with two methods,
one specialized to <fixnum>, the other to <bignum>.