This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-22
Channels
- # beginners (114)
- # boot (10)
- # cljs-dev (18)
- # clojure (57)
- # clojure-russia (12)
- # clojure-spec (2)
- # clojure-uk (1)
- # clojurescript (62)
- # cursive (49)
- # datomic (3)
- # emacs (2)
- # mount (1)
- # off-topic (25)
- # onyx (58)
- # pedestal (5)
- # re-frame (5)
- # ring-swagger (1)
- # specter (8)
- # unrepl (2)
- # untangled (4)
- # vim (10)
- # yada (39)
When I go to compile, I'm getting an error that I have a duplicate case test constant on a line where I don't even have a case
. Here is the file in question (line 35 is where it says the error is): https://hastebin.com/ecucawobev.cljs
Here is the full error: https://hastebin.com/oliciqupaj.txt
using :hooks [leiningen.cljsbuild]
how to select the build id that I want to target?
I also have no idea where '6'
is coming from, since the only case
I use in the file doesn't have that :thinking_face:
@tech_hutch is line 36 an infinite loop caused by not adding an extra arg?
oh wait, no, the underscore means they are duplicate arities
I bet that's the real error, and the message is just hallucinating
How does the underscore mean duplicate arities?
it's an argument
which means you have the same argument count twice
I'm not using that arity now, but that was just to throw away an extra argument, if it was given
two of the same arity is invalid, that arity is defined twice
How so?
clojure multi-arity functions can only dispatch on argument count
so two "arity definitions" that have the same arity, is invalid
I'm not sure what you mean. The first arity has an additional (unused) argument.
no it does not
it has the same arg count, but one is unnamed
Oh! Whoops!
Thanks for pointing that out
What a strange error message, though :thinking_face:
it would be nice if the compiler could give you that error directly (I bet the stack trace was created inside the unwrapping / rewriting of the form)
6 is a duplicate case: two arg counts that are both 6
Okay, that makes a little more sense I guess haha
@tech_hutch Are you sure it doesn't have a ".js" on the end of filename in question?
As it says in the error, it's debug.cljs. Why?
ah, yeah, I thought I saw something like that recently. But after looking your error message, not sure.
@lockdown- Someone was talking about that recently, I believe. You may want to check the logs. But according to Mike Fikes, it can definitely result in different JS being produced by the CLJS compiler. See here: http://blog.fikesfarm.com/posts/2015-06-15-clojurescript-case-constants.html
What's that .-target
and .-value
in https://reagent-project.github.io/ ?
In CLJS, the .-
syntax gets at the value of the property on a particular object. Whereas the .
syntax invokes the method of a particular object. So, .next
might invoke the next execution of the next
method, but .-next
gets the value stored in a property called next
.
Both dot operators are for doing host interop. On CLJS, we have both the dot operator and the dot-dash operator. On CLJ (on Java), we have only the dot operator.
This is because, in javascript land, we don't have an easy way of differentiating between which fields are value properties and which are methods.
So, for CLJ, yes, the dotted function syntax is for interop between CLJ and all Java libraries.
and in CLJS the dotted and dot-dashed syntax is for interop between CLJS and all JavaScript libraries.
Okay, makes sense. So an r/atom has as default some property called target, which in turn has a property called value?
close, but not quite. I suppose you're talking about (swap! bmi-data assoc param (.-target.value e))
because this is a Lisp, the first item in the list is the function operating on every other item in the list. In this case, swap!
always takes the atom it is operating on as the first argument.
in this particular example, e
is the event value that is usually passed to a callback in JS-land.
so there looking at this line, it looks like, because the second argument to swap!
is an assoc
, the value in the atom is probably a map. swap!
always supplies the value of the atom as the first argument to the function passed into swap!
s second argument.
Well actually I was talking about the component atom-input in one of the simpler examples
So we are assoc
ing param
as a key on the map in the atom, with the value returned by (.-target.value e)
but same deal, we are working with an onChange
listener in JS land. This always supplies an event
object to the callback being supplied. In this instance, we're using an anonymous function, so event
or what's usually called e
in many examples, is just %
here.
inside target
there are apparently more fields we can access, one of which is called value
We can see that neither of those are method invocations, because they are both dot-dash operators.
I think I get it now. So an event handler like :on-change has that implicit event, to which you can refer to with % in an anonymous function, or like (fn [event] ...)
@john @riz .-
was also added to CLJ, when CLJS became popular, for cross-platform reasons. So thankfully there's no reason to write CLJ code differently. When CLJ sees .-
it treats it pretty much the same as .
@tbaldridge didn't know that! thanks.