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.