fixnum macros vs procedures
Per Bothner 15 May 2017 05:22 UTC
Since the point is fixnum operators is performance, would it make sense to
make it unspecified whether the various operators (such as fx+) are procedures
or macros?
For example for Kawa it might make sense define fx+ as
(define-syntax fx+
(syntax-rules ()
((_ x y)
(+ (as int x) (as int y)))))
and that would provide decent performance, using an inline iadd JVM instruction.
However:
(define (fx+ x::int y::int)::int
(+ x y))
would require a little more work for equivalent performance.
That definition would avoid boxing, and the JVM could probably
inline the method, but it would be better for Kawa to generate
the iadd opcode directly, rather then depend on the JVM.
It would not be difficult in Kawa to define fx+ so it would inline
to a single iadd instruction - but it would be a bit more work.
Using a macro would avoid that extra work.
Why would anyone ever want to use fx+ *except* in a procedure call?
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/