Chainable aget #9

Merged
merged 2 commits into from Jun 10, 2011

Conversation

Projects
None yet
2 participants
Contributor

christophermaier commented Jun 3, 2011

I tweaked aget to accept multiple keys, allowing you to generate Javascript code like this:

foo[bar][baz]

using Scriptjure code like this:

(aget foo bar baz)

instead of this:

(aget (aget foo bar) baz)

It's backward compatible with the current aget behavior, so it won't break anyone's code. I added tests for this new functionality, as well as documentation in the README file.

An alternative approach might be to create a new special form: aget-in. Like clojure.core/get-in, aget-in would accept a vector of keys (as opposed to a vararg with '&'). This might be better in the long run, as it would allow you to easily create key sequences programmatically. It's also closer to Clojure's approach, which is always nice. If you like that approach better (and the idea of this patch in general), I'll make the necessary changes and resubmit.

Thanks,
Chris

Christopher ... added some commits Jun 3, 2011

arohner merged commit 78ed175 into arohner:master Jun 10, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment