| I just thought of something. List-ref takes an integer index as argument, and in Arc a list in functional position translates to list-ref. What if the argument was also allowed to be a symbol, in which case the list elements were treated as interleaving keys and values? arc> (= foo '(a 1.3 b 42 c "bar"))
(a 1.3 b 42 c "bar")
arc> foo.1
1.3
arc> foo!b
42
arc>
It would then be trivial to write functions with keyword arguments without adding support for that to the language. arc> (def bar (a0 a1 a2 . kvp)
(list a1 kvp!b))
#<procedure: bar>
arc> (bar 1 2 3 'a 4 'b 5)
(2 5)
arc>
This is not a full blown keyword argument implementation, though. The function signature does not reveal recognized keys (must be documented in the docstring), and there are no default forms. On the other hand, it kind of seems like the Arc way. |