Hi Jeff,

I’d be glad to help! 

The macros below look fundamentally fine to me—I tried them in bootstrapped 
ClojureScript and things are fine.

I tried further using that branch, to see if it works for me. Specifically I 
tried requiring clojure.core.matrix, but that namespace appears to attempt to 
use itself for macros (it has a :cljs condition that :require-macros for 
itself), and since bootstrapped macros are compiled as ClojureScript, when this 
selfsame file is loaded, it attempts to recursively process things in the same 
way, and stack overflows. (In other words, I think you can’t use the “loop” 
pattern (see bottom section of 
http://blog.fikesfarm.com/posts/2015-12-18-clojurescript-macro-tower-and-loop.html
 
<http://blog.fikesfarm.com/posts/2015-12-18-clojurescript-macro-tower-and-loop.html>)
 in bootstrap; it can only be used in JVM ClojureScript.

I’d be glad to help sort out issues in getting this stuff straightened out, 
though. If you are on IRC or Slack, perhaps it would be easier to have a dialog 
about it. Or, if nothing else, perhaps emails off this mailing list—I suspect 
there could be several details to discuss that might be a lot of traffic for 
the mailing list.

- Mike Fikes

> On Jan 16, 2016, at 5:30 PM, [email protected] wrote:
> 
> Hi Clojurescripters,
> 
>  I've been chipping away on core.matrix support for Clojurescript, but I 
> could use some help figuring out some final macro issues that are breaking 
> the unit tests and driving me nuts.
> 
> For anyone motivated, we've got a cljc branch here:
> 
>    https://github.com/thinktopic/core.matrix/tree/cljc
> 
> which is using the matrix branch of the ndarray library for cljs here:
> 
>    https://github.com/thinktopic/ndarray/tree/matrix
> 
> 
> In short, I think the problem is that there are a few macros which need to 
> differ between Clojure and Clojurescript.  Here are two examples from 
> clojure.core.matrix.macros.cljc:
> 
> 
> (defmacro error
>  "Throws an error with the provided message(s)"
>  ([& vals]
>   `(throw (#? (:clj RuntimeException.
>                :cljs js/Error.)
>               (str ~@vals)))))
> 
> (defmacro error?
>  "Returns true if executing body throws an error, false otherwise."
>  ([& body]
>    `(try
>       ~@body
>       false
>       (catch #?(:clj Throwable :cljs js/Error) t#
>         true))))
> 
> 
> What I'm unclear about is how conditional compilation works in such 
> situations.  By definition macros are in Clojure, but I need to have 
> different versions of the macro compile for clj and cljs.  When I try to 
> build cljc files that refer to these macros I get errors, that either they 
> don't exist, or that js/Error is an invalid java class.  How should such 
> situations be handled?
> 
> Thanks,
> Jeff
> 
> P.S.  The good news is: it works!  We can matrix multiply core.matrix arrays 
> in the browser.  Lots of very cool stuff to follow, but I need to get the 
> tests passing to get these changes merged upstream.
> 
> -- 
> 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.

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