apricot-lang / apricot

Clojure-like Lisp on Rubinius
94 stars 7 forks source link

Destructuring in let, fn, and loop #46

Closed solson closed 9 years ago

solson commented 11 years ago

We should add vector and map (Array and Hash) destructuring as in Clojure. (See link for examples.)

samflores commented 11 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])
solson commented 11 years ago

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.

solson commented 11 years ago

I'm currently implementing this syntax:

(fn foo [a b ? (c 1) (d 2) & rest] ...)
solson commented 9 years ago

I'm closing this since Apricot is effectively abandoned, but I'm open to pull requests if anyone is interested.