3 ms·
What's wrong with Common Lisp's keyword arguments? I'm not being snarky, just asking. I'd say CL works at least as well as Python in this respect.
by anghyflawn 15y ago
What's wrong with Common Lisp's keyword arguments? I'm not being snarky, just asking. I'd say CL works at least as well as Python in this respect.
- akkartik 15y agoNo, in Common Lisp you can't mix a keyword arg for a non-keyword param, or vice versa.
- arethuza 15y agoCouldn't you write a macro to call functions using whatever mixture of keyword and non-keyword params you wanted? Or perhaps using some CLOS magic do to do this behind the scenes, e.g. no-applicable-method http://www.lispworks.com/documentation/HyperSpec/Body/f_no_app.htm#no-applicable-method http://www.lispworks.com/documentation/HyperSpec/Body/f_no_a... [NB It's been a long time since I did much Lisp]
- akkartik 15y agoYes, that's basically what my repo does. It started out as an attempt to build 'arc using macros atop Common Lisp' like the original critics claimed could be done. I pretty much succeeded (and I've been told it's very readable) except that I ended up with a lisp-2. (Lately I've been building it in naked C to get out of that constraint: http://github.com/akkartik/wart/tree/unstable http://github.com/akkartik/wart/tree/unstable) I wasn't aware of no-applicable-method; thanks for that pointer.
- sedachv 15y agoYou can do (&rest all-args &key keyword1 (keyword 2 default2)) and then try to figure out all-args in the function body. How does Python handle mixing order of specifying keyword args positionally and with a keyword?
- akkartik 15y agoPython requires all args following a keyword arg to be keyword args: >>> def foo(a=0, b=1, c=2): return [a, b, c]; ... >>> foo(34) [34, 1, 2] >>> foo(b=34) [0, 34, 2] >>> foo(b=34, 35) File "<stdin>", line 1 SyntaxError: non-keyword arg after keyword arg I chose instead to simply bind args by position after keyword args have been taken: wart> (foo :b 34 35) (35 34 2)