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