This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-12
Channels
- # beginners (34)
- # boot (14)
- # cider (2)
- # cljs-dev (21)
- # cljsrn (1)
- # clojure (31)
- # clojure-android (10)
- # clojure-spec (12)
- # clojure-uk (3)
- # clojurescript (64)
- # cursive (31)
- # data-science (9)
- # datomic (27)
- # fulcro (11)
- # graphql (14)
- # jobs (1)
- # leiningen (1)
- # lumo (27)
- # off-topic (65)
- # om (2)
- # onyx (77)
- # pedestal (1)
- # re-frame (4)
- # shadow-cljs (6)
- # vim (1)
- # yada (3)
@mfikes Thanks for the writeup and suggestion, I didn't know about the ^:const
stuff. Inability to filter require
s 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.
@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.
yes, if it has no dependencies. if it requires your other namespaces it should be sorted/loaded accordingly.
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?
@zentrope Thankyou.
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?You could use https://github.com/Engelberg/better-cond
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)]
,,,)
@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.
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.
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 ?
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?
@oliver.mooney I think it's better to ask this in #cljs-dev
why javascript classes arent implemented in clojurescript? Google Closure problem? clojurescript "model" problem? WIP? Just not implemented yet?
@souenzzo why can't you? https://github.com/clojure/clojurescript/wiki/Working-with-Javascript-classes
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.
@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.
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)
@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.
@mfikes https://gist.github.com/jeaye/eaa8da70171a538e23b3c5dbfd9797fd#file-arity-broken-cljc-L20 That line should throw, but it doesn't throw for me in ClojureScript.
Right. Any call to (arities "bad")
throws for me in that setup, including when invoking it from within the test.
@jeaye If it helps, I've added a full transcript comment to your gist, showing it working for me.
@mfikes Would you mind cloning this and running the tests? https://github.com/jeaye/cljs-arity-spec-issue
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.
In other words, something based on https://clojurescript.org/guides/quick-start#production-builds
The guidelines for reporting are here, FWIW: https://clojurescript.org/community/reporting-issues