Oops, I accidentally posted this before I finished typing it.  I guess most 
of what I was trying to convey made it through.

The second ns form I posted is my suggested approach.  It requires no 
modifications to the Clojure language, and would be pretty simple to 
implement in the ClojureScript compiler.  I'd be more than happy to 
implement such support if people thought it was desirable.

-Evan

On Tuesday, March 20, 2012 10:12:43 PM UTC-7, Evan Mezeske wrote:
>
> Hi,
>
> I'm working on some tools for making it easier to share generic Clojure 
> code between Clojure and ClojureScript, and one problem that does not seem 
> to have a pretty solution is that of requiring macros.  Clojure uses a 
> regular (:require ...) whereas ClojureScript needs a (:require-macros ...). 
>  I understand that the distinction is necessary for ClojureScript because 
> macros are written in Clojure.
>
> This difference in the (ns ...) form is troublesome when trying to share 
> code between the two languages.  Right now, the only solution is to 
> copy+edit the shared file (possibly with an automated tool) so that it has 
> :require and :require-macros as appropriate.  This is not very pretty.
>
> So that gets me to wondering, has anyone brought up the idea of using 
> metadata to identify macro namespaces?  So instead of using 
> :require-macros, :require would be used, but each namespace identifier 
> would be inspected to see if it had ^{:macros true}.
>  
>
> ; The existing way to require macros from ClojureScript:
>
> (ns example.shared
>   (:require-macros
>     [example.macros :as macros])
>   (:require
>     [example.other :as other]))
>
>  
>
> (ns example.shared
>   (:require
>     ^:macros [example.macros :as macros]
>     [example.other :as other]))
>
>

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