Arc Forumnew | comments | leaders | submitlogin
1 point by Pauan 4952 days ago | link | parent

I'm going to answer my own questions.

  (car '(:a 1)) -> (keyword a)


  (let '(a b c) '(1 :c 2 3)
    (list a b c))

  -> (1 (keyword c) 2)


  (:a 1 :b 2) -> ((keyword a) 1 (keyword b) 2)


  (let (:a :b :c) foo ...)
---

"The downside is... then you wouldn't be able to use `apply` to generically call any function."

Nope. It'll work fine. When a function has rest args, any keyword args that don't match will be passed verbatim into the rest args list. Thus:

  (def foo args args)

  (foo :a 1 :b 2) -> ((keyword a) 1 (keyword b) 2)
If the function doesn't have rest args, then calling it with a keyword arg that it doesn't recognize will result in an error:

  (def foo (a b c))

  (foo :d 1) -> error: invalid keyword argument 'd