It wasn't intentional that aset not be variadic, I'm surprised no one has
ever opened a ticket for this. Fixed in master and it inlines into
efficient javascript:

(defn bad-code [obj val]
  (aset obj "inner" "number" 10)
  (aset val "inner" "count" (+ 10 (aget obj "inner" "count")))




On Sun, May 12, 2013 at 5:37 AM, zcaudate <z...@caudate.me> wrote:

> This is a quick and dirty release for interested parties. I found it very
> useful when working with angularjs. The syntax should not change that much
> but there will be more documentation in the future. I would love to have
> some input into additional features that could be added.
>
> Excerpt from Github: https://github.com/zcaudate/purnam
>
> Installation
>
> In your project file, add
>
> [purnam "0.0.9"]
>
> Why?
>
> Because the javascript dot-notation is awesome and the
> javascript/clojurescript interop (aget aset, .<fn> and .-<prop>accessors)
> make for really ugly code. Using the language-extension macros,
> clojurescript becomes more than twice as concise when working with existing
> javascript libraries (I'm mainly working with angularjs).
>
> So the use case can be seen below:
> <https://github.com/zcaudate/purnam#getters>Getters:
>
> ## javascript (12 keystrokes):
> object.a.b.c
>
> ## clojurescript (45 keystrokes):
> (-> object
>   (aget "a")
>   (aget "b")
>   (aget "c"))
>
> ## clojurescript + purnam (16 keystrokes):
> (? object.a.b.c)
>
> <https://github.com/zcaudate/purnam#setters>Setters:
>
> ## javascript (17 keystrokes):
> object.a.b.c = 10
>
> ## clojurescript (48 keystrokes):
> (-> object
>   (aget "a")
>   (aget "b")
>   (aset "c" 10))
>
> ## clojurescript + purnam (19 keystrokes):
> (! object.a.b.c 10)
>
> <https://github.com/zcaudate/purnam#functions>Functions:
>
> These are really bad examples of code but its what usually happens when
> working with existing javascript libraries. Using the dot-notation can save
> alot of screen and head space:
>
> ## javascript (~100 chars):
> var bad_code = function(obj, val){
>   obj.inner.number = 10;
>   val.inner.count = obj.inner.count + 10;}
>
> ## clojurescript (~180 chars):
> (defn bad-code [obj val]
>   (-> obj (aget "inner") (aset "number" 10))
>   (-> val
>       (aget "inner")
>       (aset "count"
>             (+ 10 (-> obj (aget "inner") (aget "count")))))
>   nil)
>
> ## clojurescript + purnam (~110 chars):
> (def.n bad-code [obj val]
>   (! obj.inner.number 10)
>   (! val.inner.count
>      (+ 10 obj.inner.count))
>   nil)
>
> <https://github.com/zcaudate/purnam#installation>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to