Closed solson closed 9 years ago
The syntax for optional args in fn
forms won't play well with destructuring.
I don't like adding identifiers with syntax purposes, but I think there aren't many options here. My suggestion is something like:
(fn func-name [a b ? [c 1 d 2]] [a b c d])
I haven't had a lot of time to look at this recently. Sorry for my late reply!
Optional argument syntax definitely needs to be changed. A thought I had a while ago was something like this:
(fn foo [a b (c 1) (d 2) & rest] ...)
That doesn't conflict with anything else that currently exists, as far as I know.
I'm currently implementing this syntax:
(fn foo [a b ? (c 1) (d 2) & rest] ...)
I'm closing this since Apricot is effectively abandoned, but I'm open to pull requests if anyone is interested.
We should add vector and map (Array and Hash) destructuring as in Clojure. (See link for examples.)