On Mon, Aug 8, 2011 at 12:59 PM, Alen Ribic <alen.ri...@gmail.com> wrote:
> It seems that the only way to reference Clojure code [1] from the
> ClojureScript namespace is via the ns require-macros keyword.
> Is this correct and if so, why the reference to macros only and not to
> general functions too. (I'm sure there is a good reason if it is the
> case; I'm hoping to get a better understanding).

Clojure is not available to the JavaScript runtime that is actually
executing the ClojureScript.  It is often easy to port some Clojure
code to ClojureScript but of course in that case it's actually
ClojureScript code with is easy enough to :require in your
ClojureScript code.

:require-macros is different because macros are only used at *compile*
time.  So you can :require-macros to pull in a Clojure namespace, and
those Clojure macros can use any Clojure functions they want to, but
that all happens while the ClojureScript is being compiled.  The
macros must produce valid ClojureScript code so that it can be
compiled to JavaScript, at which point it has lost all access to
Clojure and must make do with ClojureScript and JavaScript functions.

--Chouser

-- 
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