[gambit-list] Any way to reach generic + etc. from code with (declare (fixnum))
Marc Feeley
feeley at iro.umontreal.ca
Mon Nov 4 10:46:46 EST 2013
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+)
x
x))
(define (double2 x)
((let () (declare (generic)) +) ;; uses generic +
x
x))
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.
Marc
More information about the Gambit-list
mailing list