[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] FILE* interface

From: felix
Subject: Re: [Chicken-users] FILE* interface
Date: Mon, 8 Jul 2002 09:12:50 +0200

> I do have a question though, while I've not implemented a few API calls
> to their complicatedness, there is one of them that should be implemented.
> It looks like this:
> char* mpf_get_str(char *str, mp_exp_t *expptr, int base, size_t n_digits,
> mpf_t op);
> Now, the way this functions works is that you pass it a 'op' mpf_t
> variable, 'n_digits' worth of the manitssa you desire, the 'base' the
> number is in, and 'str' space to write the mantissa(however, if str is
> NULL, then return dynamic memory containing the mantissa and this is
> the only case I am interested in right now).
> So, there is one parameter left: 'expptr'.
> The way this parameter works is that it is a pointer to a single mp_exp_t
> variable that gets filled in with the exponent of the floating point
> What would be the best way of implementing this? I suppose I could
> return a list of two things, the car being the string mantissa and the
> cdr being the exponent, or I could try to do it some other way involving
> allocating memory for the variable to write the exponent in and then
> passing a pointer to it somehow. I am leaning toward the former of
> returning a list of two values since that is more scheme-like.

Well, it depends. I'd say the MP interface is rather low-level, and should
be accessible via a high-level layer, so efficiency is perhaps more
(which would mean, that passing a pointer or using a static buffer is ok).
But if you would like to provide a nice interface for direct user-level
access then I would favour the list-approach.

> P.S. I still think you should think about how foreign typedefs can be
> implemented in a generic fashion. :) As I'm looking at more things
> to port to chicken, I'm noticing they are quite pervasive, and very
> os/architecture dependent.

Do you mean sth like `(define-foreign-type TYPE "FOO")' ? Sorry, I don't
know how to implement this, yet. The basic problem is that we have to
memory for arguments/results of these types and then have to decide on how
to handle these objects. Should they be passed as pointers or directly?
(Hm, one could use `sizeof()' and just try it... I will take a look)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]