libera/#commonlisp - IRC Chatlog
Search
21:30:48
nij-
A potential issue of using cl-generic is that generic functions may be slower than ordinary functions because it is "too dynamic">
21:35:06
bike
well, as far as i know no implementations do static optimizations of generic function calls, although sicl is slated to. heisig has a few libraries that might be of interest https://github.com/marcoheisig/fast-generic-functions
21:35:23
bike
of course, as usual you should experimentally determine that this is actually a problem for you before you bother
6:05:53
beach
The usual "solution" is to have + and * call something like BINARY-+ and BINARY-* and to make those generic.
6:07:38
hayley
Prefix Dylan did, infix Dylan only has binary functions for such mathematical operators.
8:47:43
ogamita
To extend arithmetic to currency amount, I shadowed and redefined those functions as normal functions (since &rest args), and processed the argument types: https://github.com/informatimago/lisp/blob/782607d960853d3269be963ded246ae2875a4139/common-lisp/invoice/invoice.lisp#L392
8:48:35
ogamita
Using normal generic function dispatch may not work, because there may be more sophisticated rules. We may use associativity and commutativity, and coerce the values.