Fork me on GitHub
#clojurescript
<
2016-06-06
>
leeondamiky02:06:13

Hi, playing around with cljs.spec. I can currently instrument individual functions however when i call functions to do with multiple vars such as instrument-all, instrument-ns or speced-vars i get a null pointer exception. Sorry if this is nooby!

dnolen02:06:11

@leeondamiky: not nooby - cljs.spec is very new - show a minimal example of the problem and the corresponding stacktrace - thanks

dnolen02:06:37

I definitely don’t see that problem with (cljs.spec/speced-vars)

aengelberg05:06:47

Apparently (identical? :a :a) => false in cljs but not clj. Is this intended behavior?

niwinz05:06:32

hmm, seems like a bug

rauh05:06:51

"ClojureScript keywords are not guaranteed to be identical?, for fast equality testing use keyword-identical? "

bensu05:06:16

is there any template to use cljs-bootstrap?

jaguard07:06:56

There is idiomatic ClojureScript wrapper for Angular2 ? I'm thinking about something similar to the ReactJS ones like OmNext, Reagent or Rum. I'm mostly interested into the cross-platform renderer support available into Angular2 platform (not just a web framework anymore!) targeting mobile (ex: NativeScript, ReactNative) & desktop (Windows 10 UWP, ElectronJS ).

rnandan27308:06:20

Need a suggestion, which is the right combination to use semantic-ui, raegent+semantic-ui , or om+semantic-ui?

plexus08:06:01

@rnandan273: I guess the question is if you prefer Reagent or Om 🙂

plexus08:06:06

I'm (unsuprisingly) having some trouble with trying to use cljs.spec from bootstrapped clojurescript

rnandan27308:06:10

i would prefer reagent or re-frame,

plexus08:06:30

I'm using replumb, added a load-fn! based on XhrIo, and some server side code to hook up to it, so far so good

plexus08:06:14

starts off well:

load-inlined:  {:name cljs.spec, :macros nil, :path cljs/spec} core.js:130:8
load-inlined:  {:name goog.object, :macros nil, :path goog/object} core.js:130:8
load-inlined:  {:name cljs.core, :macros nil, :path cljs/core} core.js:130:8
load-inlined:  {:name goog.string, :macros nil, :path goog/string} core.js:130:8
load-inlined:  {:name goog.array, :macros nil, :path goog/array} core.js:130:8
load-inlined:  {:name goog.string.StringBuffer, :macros nil, :path goog/string/StringBuffer} core.js:130:8

plexus08:06:40

but then I get

WARNING: No such namespace: cljs.core$macros, could not locate cljs/core$macros.cljs, cljs/core$macros.cljc, or Closure namespace "" at line 2513  core.js:152:8
WARNING: Use of undeclared Var cljs.core$macros/mod at line 2513  core.js:152:8
ERROR - cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2 is not a function core.js:63:8
TypeError: cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2 is not a function

plexus08:06:04

any ideas what's going on here?

plexus08:06:52

I suppose the macros from cljs/core.cljc aren't loaded, but it's not trying to load them either (=> :macros nil)

asolovyov09:06:26

I have a weird problem, my production build started dying in Chrome and Firefox (it works in Safari) with an exception 'q is not a constructor' in this function:

g.$a = function() {
    return this.i + 1 < this.J.length ? new q(this.J, this.i + 1, null) : null;
};
I have determined that this is implementation of rest on IndexedSeq, which looks like that:
(-rest [_] (if (< (inc i) (alength arr))
               (IndexedSeq. arr (inc i) nil)
               (list)))
Also, this q thing is actually a DOM object - <div class="product-info">. It has no id, and I'm really puzzled at what's going on here. Any ideas what can cause that? Changes from release where this not happens to release where this happens are pretty small and don't do anything weird.

asolovyov09:06:58

This looks like an unfortunate case of renaming, since build where it happens has wildly different names of everything 🙂 (compared to the one where it doesnt)

rohit09:06:10

@asolovyov: any chance you can share a minimal cljs failing example?

asolovyov09:06:33

@rohit: I don't think I can! Actually, when I build this locally, it doesn't happen!

asolovyov09:06:47

I guess because it also uses different names? I'll check that

asolovyov09:06:13

not really... most of the names are the same. But it doesn't fail 😕

rohit09:06:28

@asolovyov: so the builds on your dev box and production box are similar but somehow the latter one fails? am i getting that right?

asolovyov09:06:29

it seems so! I'm trying to verify I'm building the same revision right now.

asolovyov09:06:09

weird... it seems I'm building same version, but it still is a bit different. I wonder if Gitlab somehow reuses artifacts of previous compilations?..

asolovyov09:06:52

doesn't seem so...

asolovyov09:06:49

ok, it's even worse:

asolovyov09:06:03

I've copied production build locally and it doesn't generate the same error it does on staging

asolovyov09:06:14

I've double-checked and that's true, it really is weird :((

rohit09:06:06

@asolovyov: it does look weird

asolovyov09:06:10

oh, right, thanks

rohit09:06:42

worth trying

asolovyov10:06:21

@rohit: of course with :pseudo-names there are no problems 🙂

rohit10:06:32

@asolovyov: it looks to me that you are using some external js objects in your cljs code but the compiler isn't aware of them.

asolovyov10:06:30

hmm... well, I do use a few external libraries (starting with React), but q?

asolovyov10:06:54

also, I had no problems like that for almost a year, and last release somehow triggered that

rohit10:06:55

how are the js libraries packaged? using cljsjs?

asolovyov10:06:12

externs, all that stuff, I keep myself tidy!

rohit10:06:14

it could be that a new version of a cljsjs packaged lib is missing an extern. but all this is highly speculative

asolovyov10:06:57

well, between failing and not failing release I have 4 commits in total, and all of them look really innocent. I guess I should try building every one of them as release. It really sucks that I can't verify anything locally - uberjar + cljs compilation cause release to take quite a bit of time...

asolovyov10:06:04

but I guess there is no workaround

dgellow12:06:56

hey guys, is there a way to get autocompletion for google closure libraries when working with a clojurescript repl?

darwin12:06:50

@dgellow: just tested it here, and Dirac does not support it in current version, but I could make it work: https://github.com/binaryage/dirac/releases/tag/v0.6.0

dgellow12:06:54

wow, I didn’t know about dirac

darwin12:06:36

that is expected, it is pretty new project 🙂

dgellow12:06:32

Ooooh, I can see on your screenshots that with dirac you have completion for js/… functions right?

dgellow12:06:57

That’s great, that’s something I definitely want with cider.

darwin12:06:47

yes, js/ completions use standard javascript completions subsystem in devtools

darwin12:06:50

not sure how Cider implements code completions for cljs, but it won’t be easy to do to without talking to something like devtools connected to chrome via remote debugging protocol

dnolen12:06:51

@asolovyov: are you wrapping your output? :output-wrapper true is the compiler option I believe

dnolen12:06:09

@aengelberg: intended, use keyword-identical?, it’s not really possible to do the keyword interning in ClojureScript to make that work

asolovyov12:06:17

but yes, I'll have to try that I actually found commit which causes that but it looks absolutely innocent

asolovyov12:06:35

@dnolen: is it possible to import two different enums from Google Closure if they have same name - EventType?

dnolen12:06:27

@asolovyov: that doesn’t sound likely

dnolen13:06:07

@asolovyov: I thought you were describing a bug - are you talking about something you are trying to do that doesn’t work?

asolovyov13:06:09

oh, actually, I can, but then I have to refer by fully-qualified name

asolovyov13:06:15

no-no, that's two different things

asolovyov13:06:25

it's just I'm tired of this bug and switched to something else 🙂

asolovyov13:06:21

@dnolen: :output-wrapper fixes the problem!

dnolen13:06:39

@asolovyov: yes I suspected as much

asolovyov13:06:57

is there any downsides to having it on all the time?

dnolen13:06:32

@asolovyov: it might be reasonable for production builds

asolovyov13:06:35

resulting file doesn't seem any bigger...

asolovyov13:06:38

ok, cool 🙂

asolovyov13:06:01

I still wonder who could assign div.product-info to q...

anmonteiro13:06:23

if I’m dispatching a multimethod on a vector, e.g. (defmulti foo (fn [a b] [a b])) , can I specify a default value for one of the elements in defmethod ?

rauh13:06:30

@anmonteiro: What are the contents of the vec?

anmonteiro13:06:00

the first one would be a keyword or nil, the 2nd always a keyword

anmonteiro13:06:19

I suppose I can make it work using get-method in the defmethod :default

rauh13:06:47

You can ask isa? question on vector, yes. Which you can use with make-hierarchy and :hierarchy some-atom that you pass to defmulti.

anmonteiro13:06:50

@rauh: I was thinking about declaring methods with e.g. [nil :default] as a dispatch, and in the default defmethod ask for a (get-method foo [nil :default])

rauh13:06:06

Yeah that's also a good idea! @anmonteiro

anmonteiro13:06:22

I don’t have to mess with hierarchies this way 🙂

rauh13:06:33

Going the hierarchy way might be a lot of work since you'd need some prefers probably

rauh13:06:19

Also adds the value to the cache dynamically for slightly better performance.

anmonteiro14:06:21

@rauh: looks nice! let me try

danielstockton14:06:18

when and why is clojure.spec advantageous compared to pre/post assertions?

anmonteiro14:06:12

@rauh: there’s one catch

anmonteiro14:06:19

because we’re implementing a default method now, if there’s no specific implementation, get-method will return the default impl and stack overflow 💥

anmonteiro14:06:52

so we need to guard against (= recover (get-method xyz :default))

rauh14:06:10

Good catch 🙂

dnolen14:06:50

@danielstockton it does a lot of stuff beyond checking fns - you can parse code, generate test information, get free property based testing, share specs, ...

danielstockton14:06:10

@dnolen knew all those things, does that mean there is really no reason to use pre/post conditions anymore?

dnolen14:06:35

@danielstockton: they just seem complimentary

dnolen14:06:47

you can use clojure.spec with pre/post if you like

danielstockton14:06:09

doesn't that mean you're effectively writing the same thing twice? is there any benefit to that?

dnolen14:06:29

I don’t see “writing the same thing twice"

dnolen14:06:36

you can use a spec as pre or post condition

danielstockton14:06:01

but if you have the function instrumented, it will already throw an exception

dnolen14:06:24

instrumenting is about testing and development

dnolen14:06:33

I probably would never use it in production

dnolen14:06:55

however :pre / :post I would probably use for show stopping stuff

danielstockton14:06:12

i see, so instead of using instrument i should use :pre/:post with the spec

danielstockton14:06:15

they seem to achieve basically the same thing

dnolen14:06:28

instrument is incredibly invasive

dnolen14:06:35

it rewrites vars

dnolen14:06:00

which why I probably wouldn’t ever use it in prod - it’s not what it was intended for

danielstockton14:06:56

ok, i think that answers my question then spec -> documentation, generating tests, sharing specs pre/post -> throwing exceptions when specs aren't met

dnolen14:06:05

something like that - none of this cast in stone - it’s just my take based on what’s been written so far and the implementation of clojure.spec / cljs.spec

danielstockton14:06:34

yeah, im sure it will be clearer when more people start using it and writing about how they're using it, but i think you put me on the right track, thanks

danielstockton14:06:45

hmm, if i use s/valid? in a pre/post i just get assert failed how could i retain the helpful exception from instrumenting?

dnolen14:06:31

you cannot

dnolen14:06:43

but you shouldn’t be dumping that kind of stuff in production anyway

danielstockton14:06:38

don't think there is any danger in my case, since the project is intended to be open source, but i guess im trying to make clojure.spec solve different problems than it was intended for

dnolen14:06:36

@danielstockton: if it doesn’t matter for your project - then sure just instrument over pre/post

dnolen14:06:00

it’s like bootstrap - use it if makes sense and the repercussions / costs are not a big deal

xgavin14:06:31

enjoying your "a tool for thought" piece @dnolen but missing your computer modern...

dnolen15:06:30

heh, yeah I saw wasn’t working everywhere - but also not a big deal for me

xgavin15:06:02

function before form!

fasiha18:06:10

I understand that Clojure's format is a wrapper for Java formatters, but it's hard for me to explain to colleagues trying Clojure that, “yes, 99% of your code will work as-is on ClojureScript but not this one thing format, yes you have to change all your formats to cl-format or something else to work in both, sorry” 😕

dnolen18:06:23

this doesn’t seem problematic to explain

dnolen18:06:27

you’re not going to get Java formatters

dnolen18:06:51

there’s lot of stuff like this, format is just one of them

dnolen18:06:42

another huge trip up is that Clojure and ClojureScript regexes are not the same

dnolen18:06:47

we’re not going to fix that either

fasiha18:06:41

Certainly it makes sense to people who live in JVM and/or JS. To people trying Clojure as a language because I bug them, it appears as an unexpected omission. It's ok tho—I will intimidate them into overlooking the lack of a cljs format (and refer to Google Closure's version, or switch to cl-format)

darwin18:06:07

Prior introducing your colleagues to ClojureScript as a first step you should deeply apologise that there are no threads in JS or that JVM has them 😉 [just kidding]

peeja20:06:05

When I use cljs.pprint/pprint, even with very large objects, I get no newlines

peeja20:06:16

In fact,

(= (with-out-str (cljs.pprint/pprint very-large-object))
   (with-out-str (prn very-large-object)))

peeja20:06:42

Anyone have a clue as to why? Is this true for everyone, or did I screw up some config stuff?

dnolen20:06:10

there’s a bunch of heuristics as to when/how you get newlines

peeja20:06:11

I'm on 1.8.40

dnolen20:06:24

I can’t say I understand any of it, but in anycase I’ve seen newlines

dnolen20:06:44

I believe you can configure it with some knobs

niwinz20:06:26

@fasiha: there are libraries like funcool/cuerdas that already exposes a uniform api for format for cljs and clj, among other stuff related to strings

peeja20:06:42

@dnolen: Alright, I'll dig into those. Thanks!

mfikes22:06:42

@peeja my first hunch is *print-newline* is false for you

fasiha22:06:53

@niwinz: thanks! While it looks more generally useful, it looks like cuerdas' format does just string interpolation, not %d and %0.3f etc.

wilkerlucio23:06:33

I'm having a compilation issue with clojurescript 1.9.36, I'm writing an app that uses untangled and this file https://github.com/untangled-web/untangled-client/blob/f42088c84b059562a48455a71daa6e4ea08d286c/src/untangled/client/data_fetch.cljs fails to compile with Caused by: java.lang.RuntimeException: java.lang.Exception: Not supported: class cljs.tagged_literals.JSValue this issue doesn't happen with 1.9.14

wilkerlucio23:06:39

full error stack:

jr23:06:35

@wilkerlucio: I ran into a similar issue. Clojurescript moved to JSON format for the analysis cache which errors when serializing incompatible json data

jr23:06:16

only when transit-clj is included in the project

jr23:06:32

(in the latest compiler)