Looking at the this line closely from "Advanced Compilation and
Externs" [1]:
"Closure Compiler compilation never changes string literals in your
code, no matter what compilation level you use...
Whenever possible, use dot-syntax property names rather than quoted
strings. Use quoted string property names only when you don't want
Closure Compiler to rename a property at all."

Considering in this case that I don't want the compiler to rename the
property `makeHtml`, I changed the code from dot notation to bracket
notation [2] using the `aget` macro [3].

Dot notation ref
------------------------
(. (js/Showdown.converter.) makeHtml arg1 arg2)

-> (new q.Showdown.converter).Fb(...)

Bracket notation ref (working)
------------------------
((aget (js/Showdown.converter.) "makeHtml") arg1 arg2)

-> (new q.Showdown.converter).makeHtml.call(...)


@Michael Fogus: considering that the docs[1] advise the use the dot
notation over bracket notation whenever possible, would you agree that
it would be a better approach to add external libraries to :externs
option [4] specifically when compiled code makes many different
references to external code?
Additionally, IMHO, the dot notation is more concise and idiomatic,
i.e. there is no need to explicitly *get* the property.

-Alen

[1] http://code.google.com/closure/compiler/docs/api-tutorial3.html
[2] ECMA 262 Section 11.2.1 Property Accessors -
http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
[3] The `aget` macro produces a bracket notation based JS call like
so: (new q.Showdown.converter)["makeHtml"]
[4] This ticket will solve this: http://dev.clojure.org/jira/browse/CLJS-10


On Aug 5, 11:00 pm, Michael Fogus <mefo...@gmail.com> wrote:
> Well, Showdown is not really a namespace right?  It's an object in the
> global environment.  You should be able to grab it via js/Showdown and do
> all kinds of interopey things to it.
>
>  On Aug 5, 2011 4:27 PM, "Alen Ribic" <alen.ri...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Thanks Fogus for clearing that up.
>
> > Would a call to a constructor function in a namespace of a third-party
> > library be an exception for the time being? (I can't seem to see a
> > clear way you can express that via `js` namespace.)
>
> > Example:
> >> new Showdown.converter().makeHtml(~{b-txt},~{safe})
> > Showdown is the namespace and the converter function is the
> > constructor.
>
> > -Al
>
> > On Aug 5, 8:57 pm, Fogus <mefo...@gmail.com> wrote:
> >> To access global JavaScript interop thingies (a technical term) you
> >> should use the `js` namespace.  The use of `js*` should be considered
> >> a bad idea.  It's used in core, but only for very low-level
> >> operations.  It should be considered undocumented and therefore off-
> >> limits (we're working to eliminate its need).
>
> >> Look at code at the following link to see a very simple way to access
> >> global js functions:
>
> >>https://gist.github.com/1127895
>
> >> Let us know if that helps.
>
> > --
> > 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 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

Reply via email to