This is the mail archive of the guile@sources.redhat.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]

Re: After GOOPS integration: Computation with native types!


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>.

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