Search
Wednesday, 24th of May 2023, 20:45:00 UTC
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:30:59
nij-
Usually it's not an issue if the function isn't called too many times.
21:31:13
nij-
But in that case, is there anyway I can optimize the function call?
21:31:32
nij-
e.g. can I hint the compiler that in some circumstances the input must be of type X?
21:33:15
nij-
A library that redefines ordinary functions as generic functions.
21:33:26
nij-
For example, #'+ #'*.. etc.
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
21:36:44
nij-
Thanks! I will take a look.
1:02:11
char[m]
nij-: checkout generic-cl and static-dispatch-cl
5:59:51
beach
What would be the point of making + and * generic?
6:02:55
jackdaniel
I can imagine someone wishing to multiply elements in an array or matrice
6:04:02
beach
But you can't specialize any parameter, because there are no required parameters.
6:05:00
jackdaniel
then I'm not sure why
6:05:11
beach
Yeah, hence my question.
6:05:53
beach
The usual "solution" is to have + and * call something like BINARY-+ and BINARY-* and to make those generic.
6:06:01
beach
That's what Dylan does, I believe.
6:07:38
hayley
Prefix Dylan did, infix Dylan only has binary functions for such mathematical operators.
6:08:55
beach
Oh, I see. I stopped looking at Dylan when it went infix.
Thursday, 25th of May 2023, 8:45:00 UTC