Fork me on GitHub
#clojurescript
<
2017-11-12
>
Kevin Lynagh00:11:16

@mfikes Thanks for the writeup and suggestion, I didn't know about the ^:const stuff. Inability to filter requires is a dealbreaker in my situation, though --- in addition to spec, there's the entire "dev" namespace for my project, which has a lot of fns and many toplevel spec definitions.

thheller09:11:00

this you might cover with :preloads?

Kevin Lynagh22:11:41

@U05224H0W the dev namespace uses spec and other namespaces, so I don't think it'd be workable w/ :preloads --- my understanding is that it just injects the given namespace first, directly after cljs.core.

thheller07:11:31

yes, if it has no dependencies. if it requires your other namespaces it should be sorted/loaded accordingly.

metacritical05:11:04

Why do some functions in clojurescript start with a hyphen - like .-onload in js/window context or .-fillstyle in canvas context while others like .getElementById do not start with a -hyphen? Right now i am just trying out whatever works is there a method to this?

zentrope05:11:24

I think the .- denote properties, and the . prefixes denote methods.

p-himik15:11:03

Is there any way to write

(let [x (get-x)]
  (when (check-x x)
    (let [y (get-y)]
      (when (check-y y)
        (let [z (get-z)]
...
in a shorter manner?

madstap19:11:05

That would at least get rid of the nesting, like so:

(better/cond
  :let [x (get-x)]
  :when (check-x x)
  :let [y (get-y)]
  :when (check-y y)
  :let [z (get-z)]
  ,,,)

john15:11:00

or when-let

p-himik15:11:30

@U050PJ2EU How would when-let help? I don't need to check x, y etc for false-ey, I need to run a specific check.

john15:11:45

ah, of course

vemv15:11:13

@p-himik is x used for something other than the check? i.e. is it used in ...

vemv15:11:02

(same question for y)

p-himik17:11:12

@vemv Yes, they all can be used later, so I can't just inline the calls to get-*.

p-himik17:11:08

One ok-ish solution would be to create a wrapper that would accept get-* and check-* functions and would return a function that returns the value if the check is passed and nil otherwise. But it still creates a "ladder" with indentation, and it doesn't work for correct nil values.

vemv18:11:49

my thoughts exactly

p-himik17:11:03

A custom macro then, I suppose.

OliverM17:11:10

Does anyone know how to require an rpm namespace with an @-symbol in its name? I've the following entry in my :npm-deps compiler entry: "@aeaton/react-prosemirror" "^0.9.7" (It's a string rather than a keyword as keywords can't contain @-symbols) That does add the right dependency to package.json, but then the following require fails: ["@aeaton/react-prosemirror" :refer [Editor MenuBar]] with the compiler error: No such namespace: @aeaton/react-prosemirror, could not locate _CIRCA_aeaton_SLASH_react_prosemirror.cljs, _CIRCA_aeaton_SLASH_react_prosemirror.cljc, or JavaScript source providing "@aeaton/react-prosemirror" @anmonteiro ?

jeaye18:11:26

I'm seeing an inconsistency between Clojure and ClojureScript for multi-arity fdefs. https://gist.github.com/jeaye/eaa8da70171a538e23b3c5dbfd9797fd Does ClojureScript do something funky here, due to the JS host?

p-himik18:11:16

@oliver.mooney I think it's better to ask this in #cljs-dev

souenzzo22:11:44

why javascript classes arent implemented in clojurescript? Google Closure problem? clojurescript "model" problem? WIP? Just not implemented yet?

souenzzo22:11:54

class HelloMessage extends React.Component This "? kind ?" of class in js..

souenzzo22:11:54

class HelloMessage extends React.Component This "? kind ?" of class in js..

OliverM22:11:44

That's an es6 class, so I'm not sure what the exact analogue in cljs would be, but I've extended js classes in cljs before by setting the prototype to a js class.

souenzzo22:11:24

So, it's a "need design" issue?

OliverM22:11:42

@souenzzo Well, you could spin up some neat shorthand for class creation via a couple of macros. But that's not why it's not in the main language. The real reason you can't is that it goes against idiomatic Clojure. Classes are a form of information hiding, which Clojure (& Clojurescript) has negative opinions about. So you still have language facilities for the good part of object-orientated design - protocols, records, multi-methods & more - but there's nothing to help you box yourself in using information-hiding designs like classes with private members.

souenzzo22:11:11

If I write the macro using js* I will not have problems with closure compiler?

OliverM22:11:53

Macros are compiled by the Clojure compiler, not the closure compiler, but you should be able to annotate them with #js tags as required in the output without too much difficulty (if that's the route you want to go)

sundarj22:11:03

classes are just sugar for functions in js

OliverM22:11:16

The output of the Clojure compiler is what the closure compiler will consume

mfikes23:11:29

@jeaye I can't reproduce what you are describing. Specifically, both tests you have in that gist pass for me in ClojureScript 1.9.946.

jeaye23:11:50

@mfikes Oh, curious. I'm on 1.9.946 and 1.9.0-beta1.

mfikes23:11:33

@jeaye Me too. FWIW, I additionally failed to repro with Planck.

mfikes23:11:37

@jeaye Just to be clear, you expect the first test to pass, but it fails for you?

jeaye23:11:35

So the test fails.

jeaye23:11:01

Trying to make a full repo for repro.

mfikes23:11:09

Right. Any call to (arities "bad") throws for me in that setup, including when invoking it from within the test.

mfikes23:11:42

@jeaye If it helps, I've added a full transcript comment to your gist, showing it working for me.

jeaye23:11:26

Thank you. I'll get this minimal repo made and see if it still happens.

jeaye23:11:03

@mfikes Would you mind cloning this and running the tests? https://github.com/jeaye/cljs-arity-spec-issue

mfikes23:11:24

@jeaye No problem. Just a sec.

jeaye23:11:14

I've found the cause.

jeaye23:11:39

:optimizations :advanced causes this failure. When I switch to :none, tests pass.

jeaye23:11:56

So you should be able to repro by cloning and running.

mfikes23:11:15

Looks like it failed for me under Node if I'm reading it correctly.

jeaye23:11:28

Correct, the test fails for you, so that's a good repro.

jeaye23:11:59

Yep, and it passed under Clojure (line 33 of your output), @mfikes.

mfikes23:11:32

Yeah. Really smells like an error with specs under :advanced. Hmm. Good find. 🙂

jeaye23:11:49

Phew! Not crazy.

mfikes23:11:57

Sounds like a JIRA may be warranted.

jeaye23:11:13

I know they're quite particular; will this test case be sufficient?

mfikes23:11:15

It feels a little non-minimal to me, given that it involved downstream tooling. A QuickStart :advanced style small setup that shows the spec fails to trigger would probably be best.

mfikes23:11:26

The guidelines for reporting are here, FWIW: https://clojurescript.org/community/reporting-issues

jeaye23:11:56

Quite particular indeed.

mfikes23:11:33

Yeah, otherwise it really is quite difficult to quickly check if a ticket can be reproducible if it involves other stuff

mfikes23:11:00

It is unfortunate that this particular issue needs :advanced in order to repro. Otherwise a simple ticket could be written involving starting up the shipping uberjar REPL and exhibiting it right in the REPL.