Yep, that patch fixes the problem. Added comment.

As for "existence of my/bar.cljs file" - I actually don't load files at
all. All namespaces are inlined in script:
https://gist.github.com/nbeloglazov/38c1fc9a1da2eeca5b33 The only
difference between :require+include-macros and :require-macros in this case
is that with :require+include-macros my.bar will be "loaded" 2 times: first
with ":macros false" and second time with ":macros true" while with
:require-macros it's going to be loaded only once with ":macros true",
right?

On Sat, Feb 20, 2016 at 4:22 AM Mike Fikes <[email protected]> wrote:

> Hi Nikita,
>
> It is a known issue with a fix. I'd recommend trying the second patch in
> http://dev.clojure.org/jira/browse/CLJS-1521 and, if it works for you,
> please add a comment to the ticket to that effect.
>
> Also, as an aside, the way the my.foo ns form is structured, it will
> require the existence of a my.bar runtime namespace (a my/bar.cljs file).
> This is because of the way :include-macros desugars—do (doc ns) to see
> this. Alternately, you could write the my.foo ns form this way and avoid
> the need for a my/bar.cljs file:
>
> (ns my.foo
>     (:require-macros [my.bar :as b]))
>
> - Mike
>
> On Saturday, February 20, 2016 at 4:53:18 AM UTC-5, Nikita Beloglazov
> wrote:
> > Hello
> >
> >
> > I have some problems understanding how macros are handled in self-hosted
> js. Let's say I have 2 namespace: my.bar and my.foo.
> >
> >
> > my.bar:
> >
> > (ns my.bar)
> >
> > (defmacro abs [x]
> >   `(if (pos? ~x) ~x (- ~x)))
> >
> >
> > my.foo:
> >
> > (ns my.foo
> >     (:require [my.bar :as b :include-macros true]))
> >   (+ (my.bar/abs -4)
> >      (my.bar/abs 5))
> >
> >
> > This works fine. my.bar/abs is recognized as macro and expanded
> correctly:
> >
> > {:value goog.provide('my.foo');
> > goog.require('cljs.core');
> > goog.require('my.bar');
> > (((((-4) > (0)))?(-4):(- (-4))) + ((((5) > (0)))?(5):(- (5))));
> > }
> >
> >
> >  But If I try to use (+ (b/abs -4) (b/abs 5)) then compiler treats it as
> regular function:
> >
> >
> >
> > WARNING: Wrong number of args (1) passed to my.bar/abs at line 3
> > WARNING: Wrong number of args (1) passed to my.bar/abs at line 4
> > {:value goog.provide('my.foo');
> > goog.require('cljs.core');
> > goog.require('my.bar');
> > (my.bar.abs.call(null,(-4)) + my.bar.abs.call(null,(5)));
> > }
> >
> >
> > I'd expect b/abs to be resolved as macro. Am I doing something wrong or
> it is known limitation/bug in currenct self-hosted js?
> >
> >
> > Full example for node js:
> https://gist.github.com/nbeloglazov/38c1fc9a1da2eeca5b33
> >
> >
> > Thanks,
> > Nikita
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/clojurescript.

Reply via email to