[Maxima-commits] CVS: maxima/src gamma.lisp,1.44,1.45



Stavros Macrakis wrote:
> I think the clean, general way to do this is to make DIV into a macro
> in mopers.lisp. This takes zero function calls at runtime and every
> user of div gets the improvement.  Something like this:
>   
> mopers.lisp:
> (define-compiler-macro div (a b)
>   (if (and (integerp a) (integerp b))
>       `'((rat simp) ,(numerator (/ a b)) ,(denominator (/ a b)))
>       `(div2 ,a ,b)))
>
> opers.lisp:
> (defmfun div2 (x y)
>   (if (=1 x)
>       (inv y)
>       (mul x (inv y))))
>   
I haven't tried this out yet, but I agree that this is the best way.  I
don't think you need to add a div2.  Leaving div as is and adding the
compiler macro should be enough.

Incidentally, I see there's a div* that simplifies the result.

And the best part is that all lisps that we support, including gcl (!),
has define-compiler-macro.

Ray