libera/#commonlisp - IRC Chatlog
Search
4:32:32
beach
Renfield: The macro call (USE-PARAM) is expanded at compile-time, and the expansion contains the value of *MY-PARAM* at compile time. The symbol *MY-PARAM* does not appear in the expansion, so it does not appear in the body of the LET.
4:35:25
beach
Renfield: If you just do (MACROEXPAND-1 '(WINDOW::USE-PARAM)) you will see what it expands to.
4:50:30
beach
Renfield: I am not sure what you are trying to do, but if you define USE-PARAM as (DEFMACRO USE-PARAM () '`(,*MY-PARAM*)) you will get *MY-PARAM* in the expansion, rather than its value.
4:51:23
beach
ACTION is now convinced that the real use case is more complicated, and that his suggestions won't work in the real case.
12:03:53
younder
(defun string-join (&rest strings &key (sep " ")) ...) as this (string-join "the" "fat" "cat" "shat" "on" "the" "mat") gives the error "odd number of &KEY arguments". Why?
12:05:54
beach
Because every parameter is a &KEY parameter (and there is only one of them) so there must be an even number of arguments.
12:10:47
beach
Your definition means a function that takes only keyword arguments (so there must be an even number of arguments), and whatever arguments you pass are going to end up in the STRINGS &REST parameter.
12:10:49
specbot
Specifiers for keyword parameters: http://www.lispworks.com/reference/HyperSpec/Body/03_dad.htm
12:11:09
_death
"In this case the remaining arguments are used for both purposes; that is, all remaining arguments are made into a list for the rest parameter, and are also processed for the &key parameters."
12:12:41
_death
in your case, either remove &rest specifier and just pass a list of strings and possible key arguments (the sane option), or leave &rest and remove &key and do your own keyword-like processing in the function (the stareyed teenage lisper option)
12:14:44
beach
_death: How would removing the &REST parameter make it possible to pass a list of strings?
12:25:07
_death
beach: (just a small note, lambda-list keywords are specifiers.. I could've been more specific)
12:30:36
_death
ok, I'm wrong again :).. "Each element of a lambda list is either a parameter specifier or a lambda list keyword.", so the specifier would be the symbol STRINGS.. now I need to internalize this terminological update ;)
13:43:34
younder
I think I finally got the rationale after reading https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node64.html
13:45:41
jcowan
I'm done here, at least for the present. I'll still be available on #scheme (or so I expect) and #lisp (or so I expect).
15:11:28
edgar-rft
younder: Practical Common Lisp has a whole chapter about &optional, &rest, and &key parameters and what happens if you mix them with examples -> https://gigamonkeys.com/book/functions