[ClojureScript] core.async - restriction on macros inside go block?

2014-07-21 Thread Tom Locke
Hi All, I had a terrible time trying to write a convenience macro for reading from a core.async channel. The idea was to make it easier to do the common dispatch on first part of a message pattern, as in: (let [[msg args] (! my-channel)] (case msg :msg1 (let [[a b] args]

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-22 Thread Tom Locke
Thanks for your reply. That's pretty much what I'd come to understand. I'm a bit puzzled why this restriction exists though. Of course function calls can't be resolved at macro expansion time, so it makes sense that ! ! inside functions can't be found. But I don't understand why the go macro

Re: [ClojureScript] core.async - restriction on macros inside go block?

2014-07-23 Thread Tom Locke
OK I've filed this here: http://dev.clojure.org/jira/browse/ASYNC-79 In trying to create a minimal test case I tried a trivial macro (defmacro my-case [expr cases] `(case ~expr ~@cases)) inside a go block, and that worked fine, so it's more subtle than just case in a macro is broken. I

[ClojureScript] Looking for project - cljs data to HTML DOM pretty-printing

2014-11-07 Thread Tom Locke
Hi All, A while back I came across a project that could take cljs data and render it in a nice readable way as HTML. I was sure I bookmarked it, or starred the github repo, but now that I need it there is no sign of it. Google searches are proving fruitless. There is the abandoned

[ClojureScript] Re: The Essence of ClojureScript Redux

2015-01-04 Thread Tom Locke
What is the impact of all this new goodness on in-browser development? lein-figwheel + weasel has been the magic formula up until now. Is that still the case? -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you

Re: [ClojureScript] Support for prefix lists in ns?

2015-02-20 Thread Tom Locke
of the functionality provided in Clojure. This is a good thing, what's there already involves an amazing amount of complexity. David On Fri, Feb 20, 2015 at 2:48 AM, Tom Locke t...@tomlocke.com mailto:t...@tomlocke.com wrote: Are prefix lists supported in ClojureScript's (ns ...)? It seems not, unless

[ClojureScript] Re: Multimethods -- problem with :default and multiple dispatch values

2015-10-01 Thread Tom Locke
Replying to myself : ) My "good enough" solution, in case it's of use to others, is (defn set-hierarchy-root! [x root] (if-let [p (-> x parents first)] (set-hierarchy-root! p root) (derive x root))) (defn with-root [x root] (when-not (isa? x root) (set-hierarchy-root! x root))

[ClojureScript] Multimethods -- problem with :default and multiple dispatch values

2015-10-01 Thread Tom Locke
One of the benefits of Clojure(Script)'s multimethods over traditional OO polymorphism is that you can dispatch on multiple values. For example, we can dispatch on the types of all the arguments, instead of just the first one: (defmulti example (fn [x y] [(type x) (type y)])) My question is

[ClojureScript] Re: Bug (?) in clojure.spec (ClojureScript) with s/or inside s/and

2016-12-02 Thread Tom Locke
A quick follow-up - if I use s/assert instead of s/valid you can see the problem with the s/or tag (:b in this case) getting into the assertion val (s/assert (s/and (s/or :a (s/and #(empty? (::data %)) #(empty? (::path %))) :b #(= (::val %)

[ClojureScript] Re: Bug (?) in clojure.spec (ClojureScript) with s/or inside s/and

2016-12-03 Thread Tom Locke
Thanks very much - that makes sense now. I had read the guide, and not noticed the fact that conformed values can be used as the *input* to specs. I looked again and the section on composing specs with and and or makes no mention of it. This behaviour does get a mention in the section on

[ClojureScript] Bug (?) in clojure.spec (ClojureScript) with s/or inside s/and

2016-12-02 Thread Tom Locke
Hi all, I'm writing a spec for a cursor-like type - a map with some ::data, a ::path into the data, and a ::value - the value in the data at that path I've written a spec that captures the constraint that (= (get-in data path) value) (s/valid? (s/and (s/keys :req [::val ::data ::path])

[ClojureScript] Switching spec asserts on and off (at compile time)

2018-03-02 Thread Tom Locke
I'm using a fairly typical build setup with figwheel and lein, and running a repl inside Cursive. Does anyone have a nice solution for (re)building the project with *compile-asserts* either on or off? According to the docs it's "Initially set to boolean value of clojure.spec.compile-asserts

[ClojureScript] Pressure towards ever larger namespace/file

2018-10-10 Thread Tom Locke
I'm working on a library, for which I would like to expose a single namespace to users. I don't want users (including myself!) to have to remember this function comes from foo-lib, this one comes from foo-lib.utils etc. Internally, however, I would very much like to split my code up into

[ClojureScript] Re: Pressure towards ever larger namespace/file

2018-10-11 Thread Tom Locke
> Dynamic load is simply not possible due to the restrictions of the browser (all IO is async). A static load could be possible but I'm not convinced that it would actually change much. It seems to me this is a static problem that could have a static solution. Even just a static in-ns

[ClojureScript] Re: Bridging core.async / callbacks

2019-05-04 Thread Tom Locke
I don't think this addresses the issue. I'll try to state the problem more simply: Write a function that does not return until some channel event occurs. (The difficulty being that go, put! and take! all return immediately) I would argue the ability to do so is: - fundamentally

[ClojureScript] Bridging core.async / callbacks

2019-05-03 Thread Tom Locke
In the early core.async presentation, Rich argues that we should avoid putting application logic in callback handlers, and instead build the "machine like" parts of our code in the core.async model. To bridge from callback world to core.async we have put! and take! which we should call as soon