This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-06-21
Channels
- # aws (2)
- # aws-lambda (1)
- # beginners (62)
- # cider (31)
- # cljs-dev (16)
- # cljsrn (8)
- # clojure (115)
- # clojure-greece (3)
- # clojure-israel (2)
- # clojure-italy (13)
- # clojure-nl (8)
- # clojure-russia (5)
- # clojure-spec (3)
- # clojure-uk (146)
- # clojurescript (108)
- # clojutre (5)
- # code-reviews (3)
- # cursive (48)
- # datomic (22)
- # editors (20)
- # emacs (7)
- # fulcro (16)
- # graphql (10)
- # mount (2)
- # off-topic (47)
- # onyx (22)
- # re-frame (100)
- # reagent (5)
- # reitit (7)
- # ring-swagger (6)
- # rum (5)
- # shadow-cljs (51)
- # specter (2)
- # tools-deps (95)
- # vim (10)
- # yada (7)
the X/Y of this is: certain libraries like schema
and, it appears, spell-spec
, output TTY codes that assume a terminal environment. this renders the console output virtually unusable
@lee.justin.m spell-spec doesn't assume tty console
it is possible to produce colors in the console but i’d be very impressed if you’d done that
shadow-cljs turns on console print by default. i just need to figure out how to turn that off.
part of me wonders if it wouldn’t be easier and better to just redirect the console to another webpage
anyway. getting off track. all i want is readable error messages for when i do type checking. lol
@hiskennyness I get that exact warning pretty often when putting some dev tools in my global lein profile
It turned out to be pretty simple. Surprised I have not run ito it before. Maybe it is just figwheel, which I do not usually use. Anyway, the deal is I needed to require the package. The only reaon it worked is that something else did require the package. So I just added the require and figwheel stopped whining. Thanks for the input!
I seem to have some problems with inferred externs using :foreign-libs
with my own bundle.js
in combination with :global-exports
to be able to require
the exported stuff. Clojurescript correctly infers type-hinted methods when using a tag like js/foo.Object
but not when using ^foo.Object
or ^foo/Object
when foo
is correctly require
d. Is this expected behavior, and how am I supposed to use foreign-libs
with a webpack-built bundle.js
?
@the-kenny typehints are currently not resolved at all and its fine to just use ^js
as a hint
@thheller thanks! That's good to know. I think I'll just skip the global-exports
part for now then to avoid confusion
I am trying to build my application along the om-next-demo repository. When loading application state from remote It is not normalized into om-nexts default database format by the default merge function. Is this expected or am I using it wrong?
Has anybody used the doo test runner with nashorn? I keep getting the error 'Exception in thread "main" java.lang.AssertionError: Assert failed: Nashorn doesn't support :optimizations :none (not= :none optimization),' when I run 'lein doo nashorn test once'
can someone explain me the logic behind cljs.string/blank?. In jvm if i call that function with non-string value it gives classcastexception and i expect and understand that because I call type-specific function explicitly and assume no coercion to happen. in clojurescript though it uses goog.string/isEmptyOrWhitespaceSafe (which is aliased by goog.string/isEmptySafe) which makes implicit conversion of argument to string in makeSafe() function. so even for empty object I get goog.string.makeSafe({}) => "[object Object]" and the overall result is false. From where i am standing this behaviour makes no sense so it should either return exception (as it does in jvm implementation) or present some adequate result for non-string object
> True if s is nil, empty, or contains only whitespace. Honestly that matches the docstring pretty well
hm, an empty object is false, so I don’t see how it matches the doc string. however, the doc string is just meant to be about strings I’d say.
yes, and to answer @zallin the fact that clj fails with a class cast is more of an impl detail than anything I’d think
clj didn’t make any explicit attempt to give you something useful, it just fails at the JVM interop
I’m not really saying what is right or wrong, just the CLJ/CLJS “philosophy” behind it
you can only rely on what is documented and the implicit assumptions around it being a clojure.string
thing so expecting strings
CLJ has no error checking in that regard, it doesn’t do an “instance of String” check etc
You are just getting a runtime exception trying to call a String method that doesn’t exist on some non-string object
it is different than coercion in the CLJS case, but in either case, neither fn’s make any real attempt to handle non-strings, you just get something arbitrary impl depenedent
and you shouldn’t except to see cross-platform compatible code when you are relying on undocumented assumptions
I’m not always super happy about how this plays out (no errors and implicit coercion can be annoying and make it hard to know what is going on). just explaining the general mindset I think is in play here.
There have been arguments made at times that checking for all the negative cases can add measurable performance degradation etc, also maybe just adding too much code bloat. Those are the main things I’ve seen discussed on these sorts of topics
yes and from my point of view it should not anyhow handle non-strings, as you said, it is not a part of its contract
if the doc string is all about strings (which it is), then yes, it leaves a huge open space for what it does when not true
> it returns true on nil, empty, and whitespace strings. all else is false no, CLJ throws exceptions
I think you have to read doc strings and also understand this background philosophy of not often checking invalid types/values in clj/cljs
I’m not making an argument against what it does or says though, just saying the interpretation involves more than the doc string alone I think
I think it’s just a part of clj/cljs. It’s a bit hard to get used to, but once you are used to it, doesn’t really tend to be a big issue
If I have more vague places in code where I use clojure.string/blank?
for example, I defend with (and (string? s) (blank? s))
i personally do not think that behaviour on everything else is an undocumented assumption
> i personally do not think that behaviour on everything else is an undocumented assumption I don’t understand what you are saying here
i think it should be handled with some sort of convention and be consistent across platforms
to handle negative scenarios consistently would be a big undertaking. I can see some of the reason why it isn’t done
JavaScript is exceptionally terrible at allowing anything to do something without failing
clj/cljs are most brittle on this subject (in my opinion) in libs like clojure.set
and clojure.string
sometimes things work as you expect, sometimes it depends on which “set-or-not-set-coll” is passed to which argument to
but in general, it isn’t safe to call clojure.set
fn (unless explicitly allowed) with non-set coll’s
I’ve had to do a bunch of code reviews of clj code before and have had to be on the hunt for clojure.set
and clojure.string
misuse or dangerous use. So I am familiar with the subtlety
I understand your reasoning but these platform-specific logic can make life much harder
for instance I ve encountered what we discussed in .cljc file which is compiled to both envs
it can be a bit of a trick indeed, have to be careful on these topics I guess is my only advice. Know the “clojure way” and try to work with it hah
the (and (string? x) (blank? x)) is a good portable solution and you don't have to deal with exception throwing.
not really. all this predicate promises is to recognize blank strings. which is does pretty well
if it is a string fn that expects strings, the only contract is its behavior on strings. this is true in clj and cljs. You can’t rely on undocumented arbitrary impl detail behavior to be consistent across platforms
but the particulars of how Google closure ends up handling it (a) I don’t really know why (b) coercion is a very dominate thing in JS, not so much in JVM
@zallin I think we could get some mileage out of spec here to get both runtime failure and compile time checking
I’d like to have a naming convention for spec files such that we can use them as type information for Google Closure Compiler
I don’t know when I’ll have time to work on this - but I have rough idea of how I want it to work - #cljs-dev is the place to talk about that if anyone is interested
Hi all. Does anyone know why the equivalent of clojure.core/extend is not in cljs? And could it be etc? Sorry if this question has come up before... I failed to Google it. Also, I do realize a similar fn extend-type is in cljs.core. Thanks
ok thanks. Just wondering about a making a patch then... I submitted a patch for something else a while ago and not got any feedback on it https://dev.clojure.org/jira/browse/CLJS-2589. I appreciate reviewers time is short etc... but so is mine 😉 Is there any way to know when/if patches get looked at? should I try to get votes for the issue for example?
@henryw374 right thanks, yeah no one’s got around to look at one - looks ok - feel free to chime in on Fridays in #cljs-dev on stuff you want me to look at / apply
created https://dev.clojure.org/jira/browse/CLJS-2786 for cljs.core/extend impl