|
|
|
|
|
by ANTSANTS
4444 days ago
|
|
; CL keyword arg syntax, taken from Practical Common Lisp
(defun foo (&key (a 0) (b 0)) (+ a b))
(foo :a 1) -> 1
(foo :a 1 :b 2) -> 3
; hypothetical table keyword arg syntax
; clojure defines commas to be whitespace, you can pretend they aren't there if you want
(defun foo ({a: 0, b: 0}) (+ a b))
(foo {a: 1}) -> 1
(foo {a: 1, b: 2}) -> 3
I fail to see why the table syntax would be any less usable or introspectable by compilers or editors. They'd have the advantage (which would be shared with alists, if Common Lisp had used them for keyword args) of sharing the syntax for keyword args with a syntax for optional structure properties (think XML's attributes) |
|
There is nothing to be gained by hashtables.
The Common Lisp keyword syntax actually is a bit more powerful then what your PCL example shows:
(defun foo (&key ((var keyword) init var-arg-supplied-p) ...)
Generally I think it is a slight mistake to use specific data types in arglists - basically mixing syntax and data types.