Fork me on GitHub
#clojurescript
<
2015-12-06
>
munk00:12:00

I’m in need of some core.async testing expertise. I have a go block that’s not executing before my assertions, and using the async macro doesn’t seem to work. I’ve tried to put up a minimal example here: https://gist.github.com/munk/d4c63ecf2fc734fb0673 (I’m in the process of testing it, so please excuse any typos).

plexus10:12:24

I'm trying to figure out how to use macros in bootstrapped clojurescript

plexus10:12:17

one thing I notice is that for cljs.core there's a cljs.core$macros.js containing the compiled versions, but e.g. quil.core also contains macros, but there's no corresponding quil.core$macros.js

plexus10:12:50

is there anything I can do so the macros from quil.core are also compiled?

darwin11:12:15

@munk: assertion https://gist.github.com/munk/d4c63ecf2fc734fb0673#file-test-cljs-L44 will be never executed, it is sitting in a function which gets never called, why do you wrap that code with (fn [] …) ?

dnolen11:12:38

@plexus you don't need to do anything special. The rules for macros are the same as regular ClojureScript

munk13:12:01

@darwin my understanding of the async macro, which is admittedly imperfect, is that the signature is (async done body callback-with-done). So than code wrapped with the fn is supposed to be the callback

dnolen13:12:11

@munk that’s not how it works, the return value of async block isn’t used at all

darwin13:12:47

you are supposed to call (done) when your are done in body

balduncle14:12:50

Is it normal to have associated Clojure and ClojureScript code in a single project? Any community conventions or best practices on how to organize the directory structure?

jaen14:12:58

I used to have directories like src/clj/project_name/... ,`src/cljs/project_name/...` and src/cljx/project_name/... (that would probably be cljc now

jaen14:12:03

Right now I prefer something like

jaen14:12:44

src
 |--project_name
    |--backend ; or server
    |  |--clojure_namespace.clj
    |
    |--frontend ; or client
    |  |--clojurescript_namespace.cljs
    |
    |--common
       |--common_namespace.cljc

jaen14:12:50

Feels more descriptive to me

balduncle14:12:27

Yeah, I like that as well.

jaen14:12:19

So then I just have namespace like project-name.backend.components.webserver and so on. I feel it works quite well for me.

balduncle14:12:55

I’ll give it a try. I’m pretty new to Clojure and ClojureScript.

balduncle14:12:15

Trying to set up an Om Next project with Datomic on the back end.

mfikes14:12:57

@plexus: Here is an example of using a Quil macro from bootstrapped ClojureScript (the important thing being that the macros are simple and appear to be compilable as ClojureScript): https://gist.github.com/mfikes/43ccddf688e3f712392a

plexus14:12:39

@mfikes: thanks. I'm gonna have a better look at Replumb to see how these things work

munk14:12:45

@darwin: thanks! That was very helpful

mike15:12:30

I want to render a goog.ui component in a clojurescript (reagent) component. is there an example of doing this?

mike15:12:55

would that break function purity by calling goog.ui component render function?

pesterhazy15:12:04

Is there a way to turn Use of undeclared Var from a warning into an exception?

pesterhazy15:12:26

As it is, I get a warning in the console but the value is just nil. I'd prefer to have it fail, or handle the error myself.

alandipert16:12:04

anyone aware of alternate zipper impls. other than fast-zip?

dnolen17:12:51

@pesterhazy: the ClojureScript supports that but you usually need your build tool to support the hook

dnolen17:12:56

cljsbuild definitely does

pesterhazy17:12:59

dnolen: I'll see if I can find the option

mike17:12:03

I'm trying to teach myself clojurescript on weekends. unfortunately, coming from javascript, I always find myself struggling with clojure syntax. for example the following (from reagent todomvc) is really cryptic to me:

(defn mmap [m f a] (->> m (f a) (into (empty m))))
(defn complete-all [v] (swap! todos mmap map #(assoc-in % [1 :done] v)))
(defn clear-done [] (swap! todos mmap remove #(get-in % [1 :done])))

mike17:12:54

I know it tries to add/remove some values from a hash map.

mike17:12:04

the whole thing in javascript would be very readable.

mike17:12:32

but in cljs, it takes me a while to decrypt the whole thing, and even then, I struggle.

mike17:12:04

most of the time, I'm not sure if I should read thing from left to right, or right to left.

mike17:12:54

there is -> and there is ->> , I keep forgetting which one is which one simple_smile not intuitive symbolism here.

mike17:12:38

is the above really plain simple cljs, or can it be written in a more simple way?

mike17:12:38

if this is all clear to you guys, I'll have to come to the conclusion that there are 2 type of people. the ones who understand lisp, and the one who don't.

mike17:12:23

just like there are 2 type of people when it comes to editors: the ones who feel at home with vi-like style, and the ones who will never learn it.

pesterhazy17:12:32

@dnolen: I'm looking to do it in the boostrapped compiler, but cljs-warning-handlers seems to be used only in the clojure-based one

dnolen17:12:13

@pesterhazy: there might not be a hook for that, JIRA ticket + patch welcome if there isn't

pesterhazy18:12:51

@dnolen: (binding [cljs.analyzer/*cljs-warning-handlers* [#(throw (ex-info "Cljs warning" {:args %}))]]) works actually simple_smile

plexus18:12:10

Is there a way to look up a var by name in Clojurescript to get to its metadata?

dnolen18:12:45

@plexus: not dynamically at runtime, but there are compile time and static ways to do that

dnolen18:12:03

including the var special form

plexus18:12:47

ok, I can figure that out

dnolen18:12:47

@pesterhazy: ok that’s what I would have thought

dnolen18:12:18

@pesterhazy: that’s hooking somewhat into an implementation ns so no promises that will continue to work

pesterhazy18:12:58

that's okay, I'm happy it works for now

pesterhazy18:12:06

though it might be worth considering adding a STRICT mode that fails on all compiler warnings

pesterhazy18:12:07

like gcc's -Werror

dnolen18:12:37

@pesterhazy: not going to add anything like that

dnolen18:12:49

but the primitives are there for other people to do stuff like that

richiardiandrea21:12:20

@pesterhazy: in replumb I am adding (it's a PR) a :warning-as-error flag that you can pass to read-eval-call

richiardiandrea21:12:33

should be in soon

pesterhazy21:12:24

richiardiandrea: awesome!

pesterhazy21:12:46

we discovered replumb too late, but it would have been the perfect basis for our ClojureCup entry simple_smile

richiardiandrea21:12:56

Oh too bad man...what did you develop if I can ask?

mikethompson21:12:37

@mike: I recognise that code from the reagent todomvc. Don't worry, its a quite confusing bit of code for all beginners. There's a temptation in these todomvcs to keep the linecount down, and that leads to over-terseness. But don't worry, you'll get there in terms of reading it. And, of course, eventually it will be second nature.

pesterhazy22:12:57

@richiardiandrea: an interactive Quil tutorial using bootstrapped cljs and codemirror

darwin22:12:00

I wanted to cut a new release for chromex library and I hit a wall preparing jar file for distribution, I have multiple folders under src which contain duplicit files, those folders are supposed to be cherry-picked in cljsbuild builds depending if code targets chrome extension APIs or chrome apps APIs. It is easy for me to do that when using library from checkouts, but when I want to package it, those folders glue together and names collide. What is the best approach here? https://github.com/binaryage/chromex/blob/master/project.clj#L23-L29

darwin22:12:44

one idea is to prefix all my namespaces with target platform, but I’m not convinced

darwin22:12:52

I would rather like user depending on the library to somehow specify which subset of jar to use

richiardiandrea22:12:24

Similar but maybe unrelated, in replumb I am thinking of hacking my own reader conditional tag (it has been done here http://www.bytopia.org/2015/11/29/lisp-feature-expressions-clojure/) in order to solve testing with Node.js

richiardiandrea22:12:55

I was also thinking of having submodules and produce different artifacts