[ClojureScript] Idiomatic way to handle different platforms

2014-08-28 Thread Dušan Maliarik
Given a library code that one wants to work in both the browser and node.js. When it is using a browser specific API, that is available to node only through a 3rd party package, how would you re-write this piece of code? Are nested defs ok/bad/un-acceptable? (if (exists? js/process) (do (

[ClojureScript] Idiomatic way of accessing JavaScript properties in nested "namespaces"

2014-08-28 Thread Rafal Spacjer
Hello, I' curious what is a preferable way of accessing properties or methods in nested JavaScript "namespaces". Lets assume that external library define such property: Foo.Bar.Foo2.myProperty in global namespace. what is idiomatic way of accessing 'myProperty': (.-myProperty js/Foo.Bar.Foo2)

[ClojureScript] Re: Idiomatic way of accessing JavaScript properties in nested "namespaces"

2014-08-28 Thread Francis Avila
Avoid dots in the name part of symbols. "js/a.b.c" works to reference "a.b.c" by value (i.e. without calling it), but it's not idiomatic. Prefer (.. js/a -b -c), or using your examples: (.. js/Foo -Bar -Foo2 -myProperty) (.. js/Foo -Bar -Foo2 myMethod) The "js" pseudo-namespace is special becau

[ClojureScript] Re: Idiomatic way of accessing JavaScript properties in nested "namespaces"

2014-08-28 Thread Ivan L
why is it not considered idiomatic, I see that pattern used all the time. Doesn't clojure itself use fq namespaces occasionally? (just no js prefix) On Thursday, August 28, 2014 5:45:55 PM UTC-4, Francis Avila wrote: > Avoid dots in the name part of symbols. "js/a.b.c" works to reference "a.b.c

[ClojureScript] Re: Idiomatic way of accessing JavaScript properties in nested "namespaces"

2014-08-28 Thread Rafal Spacjer
Sounds good, thank you. Of course I agree, that using dots (like in "(js/console.log x)") is faster to write. W dniu czwartek, 28 sierpnia 2014 23:45:55 UTC+2 użytkownik Francis Avila napisał: > Avoid dots in the name part of symbols. "js/a.b.c" works to reference "a.b.c" > by value (i.e. witho