Fork me on GitHub
#clojurescript
<
2019-10-29
>
mattly01:10:45

I'm attempting to call a macro with a #js {} object literal, and getting a ClassCastException in the compilation phase. Is this not supported?

lilactown02:10:44

@mattly is the #js reader used in CLJS code or CLJ code?

lilactown02:10:04

#js should expand at read time before it hits your macro code

lilactown02:10:28

But if your macro is outputting it, it might not work

mattly02:10:35

It’s in the CLJS code invoking the macro

mattly02:10:48

I’ll get a little example up after I get my kid to bed

mattly03:10:05

bah, some kind of heisenbug

mattly03:10:36

went away when I tried to isolate it, and now I can't reproduce

kwladyka14:10:57

Hmm I confused myself: clj -A:fig:build

Syntax error compiling at (src/form_validator/core.cljs:9:7).
No such var: s/explain-data
(ns form-validator.core
  (:require [cljs.spec.alpha :as s]))

(def conf (atom {:atom atom}))

(defn ?spec-problems
  "Return nil if pass."
  [spec value]
  (-> (s/explain-data spec value)
      :cljs.spec.alpha/problems))
Why I have this error? I am using fighweel-main. I am sure I didn’t have it a few months ago. But when and open the same running process ( clj -A:fig:build ) in web browser or clj -A:test:test-watch it works. But when I want to use REPL directly it doesn’t work. Is it ClojureScript / figwhee-main / Cursive issue?

kwladyka14:10:01

to make it clear: I am running the REPL which work for web browser in Cursive. This is the same REPL where I am trying to load the namespace.

kwladyka14:10:01

hmm I think it is Cursive issue with figwheel-main when use deps.edn

kwladyka14:10:43

But it was working in the past hmm

kwladyka15:10:02

ok I found it. I needed to switch REPL. I didn’t remember about it.

luchini18:10:32

Folks, something very noob that I simply assumed would work. When consuming your clojurescript code from JS, it seems multimethods are not exported the same way that functions are (as in, they can't be called directly).

luchini18:10:44

What's the best way to consume multimethods from JS?

thheller18:10:11

mulitmethods are not regular JS functions. In JS you call use .call or create a regular function in CLJS that calls the multimethod

thheller18:10:33

depends on what kind of "translation" of arguments you need to do

luchini19:10:20

Does .call have the same signature as the original multimethod?

lilactown19:10:09

@luchini I would export a normal function that wraps the multimethod

thheller19:10:13

.call takes one extra first arg

thheller19:10:24

usually for JS functions thats the this the function will have

thheller19:10:28

but the multi method will just ignore it

luchini19:10:38

It's basically what we are preferring to do here @lilactown

thheller19:10:54

yeah, I would also recommend using a regular wrapper fn

Mario C.19:10:41

I want to integrate re-frame into an existing project I have. I don't want to run the lein new re-frame command since that will build a new directory with a project.clj and other stuff. If I already have a project structure should I just emulate the project structure that the script builds and look at how the script creates the project.clj and incorporate that into my existing project.clj?

luchini19:10:44

Thanks @thheller and nice work on shadow-cljs. It packs a lot of goodness.

👍 4
Mario C.19:10:49

Or is there a better way of going about it?

actonDev20:10:27

(About hot reload of cljc files in figwheel) Has anyone experienced this/has any idea? https://github.com/bhauman/figwheel-main/issues/218 I'm stuck and this thing really slows my workflow 🙂

Mario C.22:10:10

when running shadow-cljs build I get Circular dependency detected: cljs.core -> cljs.core how can I figure out whats causing this? I tried building with the --verbose option but it doesn't give me much info other than

-> build target: :browser stage: :configure
<- build target: :browser stage: :configure (8 ms)

borkdude22:10:53

there was a time when CLJS didn't have "vars" as described here: https://clojurescript.org/about/differences#_vars_and_the_global_environment when they were introduced, did this mean a drop in performance because of more indirection? and are vars compiled away in advanced compilation?

lilactown23:10:37

not sure what you mean. CLJS still doesn’t have vars, as described there :thinking_face:

borkdude23:10:58

@lilactown I mean this: > In ClojureScript def yields the value, unless the REPL option :def-emits-var is set (this defaults to true for REPLs). and this:

cljs.user=> (var assoc)
#'cljs.core/assoc

borkdude23:10:42

call it whatever you want to call it, but it's an indirection that resembles something like a var

lilactown23:10:33

I think it’s point is that, vars don’t get output in actual code. only at the REPL

lilactown23:10:08

(def foo 1) JS output is cljs.user.foo = (1);

lilactown23:10:06

if you explicitly call var in your code, it will create a special var object at the call site and yes, it does impact code size

lilactown23:10:01

ex: (var assoc)

lilactown23:10:40

but 99% of CLJS code contains no vars at all, because def does not actually return a var and it is not a part of the typical CLJS runtime

lilactown23:10:15

so vars are almost never output and advanced compilation does not deal with them at all