[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] How do I name these procedures?
From: |
Jeronimo Pellegrini |
Subject: |
Re: [Chicken-users] How do I name these procedures? |
Date: |
Thu, 15 Apr 2010 17:47:42 -0300 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Thu, Apr 15, 2010 at 10:33:51PM +0200, Thomas Chust wrote:
> Hello Jeronimo,
>
> thinking about it, I would only provide two wrappers per function: One
> destructive version that accepts two mandatory input arguments and an
> optional output argument defaulting to the first input argument. And
> one non-destructive version that accepts just the two input
> arguments and allocates an output target.
>
> The code would look like this:
>
> (define (ia+! a b #!optional [out a])
> ((foreign-lambda void "mpfi_add" c-pointer c-pointer c-pointer)
> out a b)
> out)
OK, that sounds much better!
I wonder if the optional argument would make the function call too much
slower?
> (define (ia+ a b)
> (ia+! a b (make-ia-interval)))
> I would also just prefix the operator names with characters, not
> suffix them — mostly because of the stylistic similarity to existing
> bindings like fx+.
But there's a difference between these two:
ia+ia (sums two intervals)
ia+f64 (sums an interval to a flonum)
Using only ia+ would mean checking the type inside the procedure, which
I'd like to avoid.
J.