[gambit-list] Any way to reach generic + etc. from code with (declare (fixnum))
mikael.rcv at gmail.com
Thu Nov 14 15:53:23 EST 2013
2013/11/4 Marc Feeley <feeley at iro.umontreal.ca>
> On Nov 3, 2013, at 10:01 PM, Mikael <mikael.rcv at gmail.com> wrote:
> > Dear Marc,
> > The procedure ordinarily reached as + , can it be reached under some
> alternative name in code with (declare (fixnum)) ?
> Here's how I would do it:
> (declare (standard-bindings) (fixnum) (not safe))
> (define (double1 x)
> (+ ;; uses fixnum specific + (i.e. ##fx+)
> (define (double2 x)
> ((let () (declare (generic)) +) ;; uses generic +
> You could also call the procedure ##+, but it is not an exact replacement
> for + because the error handling is different (try (##+ 1 'foo)) and it
> must be passed 2 parameters.
Weird, I tried for this x.scm :
(declare (standard-bindings) (fixnum))
(define x 97650736685728012900)
((let () (declare (generic)) +)
and it still goes:
> (load "x.scm")
> (compile-file "x.scm")
> (load "x.o1")
*** ERROR IN ##load -- (Argument 1) FIXNUM expected
(fx+ 97650736685728012900 1)
I get the same result when compiling the double2 example in your email
I tried adding another let around the +, did not resolve it.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Gambit-list