This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-14
Channels
- # aleph (14)
- # bangalore-clj (2)
- # beginners (39)
- # boot (18)
- # carry (7)
- # cider (37)
- # cljs-dev (1)
- # cljsrn (4)
- # clojure (74)
- # clojure-austin (12)
- # clojure-canada (6)
- # clojure-conj (15)
- # clojure-dev (3)
- # clojure-greece (14)
- # clojure-italy (1)
- # clojure-korea (1)
- # clojure-poland (3)
- # clojure-russia (5)
- # clojure-spec (22)
- # clojure-uk (13)
- # clojurebridge (9)
- # clojurescript (231)
- # cursive (2)
- # datascript (9)
- # datomic (12)
- # devcards (2)
- # emacs (2)
- # events (4)
- # hoplon (28)
- # off-topic (35)
- # om (61)
- # onyx (8)
- # parinfer (8)
- # proton (1)
- # re-frame (53)
- # reagent (10)
- # ring-swagger (8)
- # specter (11)
- # untangled (3)
- # vim (4)
@doglooksgood is Flatpickr
a foreign JS object?
(set! (.. js/Flatpickr -100n -weekdays) #js [])
should work
well actually it won’t work because of the 100n
prop
but it wouldn’t in JS anyway
you’ll probably need to use goog.object/set
var x = {}
undefined
x.100n = 42
Uncaught SyntaxError: Invalid or unexpected token
right
that’s an L
, not a 1
so, i’ve got a weird preamble issue. reactDOM is being inlined before react, causing this funny error: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
it’s only happening in one project. another project with the same versions, it’s fine
there is a key difference on this project: i’m using cljs’ :modules
infact, i’m not seeing the imul patch in the broken project either
lol. the preambles are reversed!
reactdom, react, imul in the one, and imul, react, reactdom in the other
faulty one is on the right
@dnolen i’m just making you aware of this ^; going to see if i can track the issue down in cljs now
should the preambles load in a specific order? i’m guessing yes, since cljsjs packages declare dependencies on each other
@martinklepsch have you perhaps encountered this behaviour?
@robert-stuttaford haven't seen this before. My guess would be that module resolution/ordering works differently when using :modules
and the case of synthetic namespaces isn't fully taken care of
thanks Martin. what’s odd is that this is only happening on our build server. my mac, it’s fine.
i’ve scanned all the code where :modules
appears, but nothing obvious jumping out at me. going to have to go deeper i guess
@robert-stuttaford would be interesting to see the logs between a normal vs failing build (with :verbose
true)
will do — just tested with cljs 1.9.36 and the behaviour doesn’t exhibit there
not sure how old that version is, i’m guessing ‘quite'
can you reproduce it 100% of the builds?
@robert-stuttaford also, there have been a few versions between 1.9.36 and 1.9.229. it would also be interesting to track down the latest one that produces the bug
i’m doing a :verbose for the broken one now
I know I’m probably asking too much, no rush at all 🙂
it’s deterministic, insofar as it always happens on our CI box
with this version
is there a good place to see a list of all the released version numbers? i don’t mind trying some versions between here and there
seems like a handful
^ those have all been published to maven
could you give me a sense of what to look for in the verbose output?
sure. so the dependencies are compiled in order
so there should probably be something in the wrong order, comparing the 2 outputs
Adding remaining namespaces to :cljs-base
has adding entry [cljsjs.react.dom]
well before adding entry [cljsjs.react]
i’m guessing that’s the output that confirms the symptom
running a ‘fixed’ build now
thanks for discussing with me, @anmonteiro 🙂
Hi! I was in here perhaps a month ago asking if anyone knew if it was possible to do interactive WebGL programming with cljs. Turns out its very much possible and I ended up writing a tutorial on the subject I thought I'd share: https://github.com/Rovanion/webgl-clojurescript-tutorial
Live rewind to the program state when a function was last modified http://dalsegno.ballingt.com/
Something like this would be possible in ClojureScript if we had stable compiled temporary variable names.
o/ bruce how’re ya goin!
doing great, thanks!
@bhauman I think, this could be done on a library level, I can imagine a set of wrapper macros, which would read/store variables in some kind of db by name (instead of relying on global state), and that can be saved/restored with another set of functions
he is speaking about resolving scope chain, I don’t fully understand this, but that could be done with js prototype chain cheaply
but you can add hooks to snapshot and restore your apps state, first and then have a system to record the apps state when changes occur and label those changes with the functions that changed
yes, I think this could be useful in some scenarios, if figwheel provided a nice UI for managing those snapshots
rewind in general is powerful, and actually a simple rewind is possible with a library, as you say
but we don't want to redefine "defn" just probably add state snapshotting and restoring and UI... but this will only work for the most disciplined of apps. And most non trivial apps have to cheat with local state in their React Components.
I think having some defn-like variant would be fine, user would mark functions explicitely
I can see marking certain functions as code change <-> data snapshots as an interesting tool
I think I just got a crazy idea, but only for ES6, which should be fine, under dev mode your could auto-wrap all clojurescript variables with ES6 proxy objects and redirect their reading/writing into that bag object I was talking about, thus effectively isolating all state (including the one closed over in closures) into one single flat object, and then you can introduce machinery for saving/restoring and managing history
the price user would pay would be one or two steps of indirection when reading/writing values
when can i play with it? 🙂 this sounds fun!
sorry, that may have come across as rude 🙂 are you guys talking about the video of the js app that rewinds when you recompile code?
@dnolen @martinklepsch turns out what @robert-stuttaford mentioned above was indeed a compiler bug. Captured in http://dev.clojure.org/jira/browse/CLJS-1821 and patch attached
my goodness, that would be a fun thing to have in cljs
@anmonteiro @robert-stuttaford did you figure out why it happened on CI but not locally?
unfortunately, no
but this patch definitely fixes it in CI. applied and reverted the fix to make very sure
well, let's thank the weird CI behavior, you found a bug! 🙂
\o/ my first Cljs patch. only took me 4 years
am I right that right now there are only two sane ways to manage NPM deps: 1. CLJSJS and maintaining stuff myself 2. http://blob.tomerweller.com/reagent-import-react-components-from-npm ?
@si14 well CLJSJS isn’t NPM stuff 🙂 but yes the simplest way for the time being is to create a single foreign dep via Webpack or whatever
@robert-stuttaford sweet! 🙂
@darwin last time I checked proxy objects were like 2-3 orders of magnitude slower than regular JS Objects - so might not be practical for many typical things
hm, good point, more involved solution would be to instead generate wrapping code directly by compiler on each access site, but that sounds like a much more work and would break js-interop
@rovanion you might also want to take a look at @kovasb’s Gamma library, he did a pretty cool talk about it at StrangeLoop 2 years ago
@darwin without fast host level support Proxy I don’t think such ideas will go very far
@dnolen I might’ve missed it but is there any plans to have a bigdec equivalent in CLJS?
given that this needs to exist in all JS targets to be practical - I suspect we’re talking 5 years out at least
@nfisher Closure Library has a bigdec, if you mean support for that with regular arithmetic operators - also probably won’t happen for many years
@bhauman another avenue of exploration would be to try to leverage V8’s own code-patching functionality, it was added for DevTools to be able to live-edit code, they do something smart there I think, this could be a solution for replacing functions that were closed over and have no global entry-point to be redefined using eval https://github.com/v8/v8/blob/80caaac31bd05649ab81c0b84b320833c96b4ed7/src/inspector/v8-debugger.cc#L354 I could implement a support for this in Dirac
@dnolen mmm I was wondering if it could be backfilled w/ something like BigDecimal.js for now. Guess it still wouldn’t fit to the Clojure model though.
it has nothing to do with existence of an implementation - and everything to do with needing to overload +
efficiently
but nothing is stopping anyone from making a generic math library for ClojureScript as a library
Yea was thinking it’d be nice to have cljc calculations that are compatible in both Clojure and CLJS.
yes, it would be awesome to have a generic numerics lib where perf isn’t the primary concern
mmm yea for my use case perf is not critical but I understand there’s a lot of cases that would desire/require it to be performant.
I guess I would be ok with saying “here’s” a special type and if I have to call custom methods to use it I’d be ok for consistency across both CLJ and CLJS.
@dnolen sorry think I’m being thick but don’t see BigDecimal as a part of the Closure library? I assumed it would be goog.math?
@nfisher: oops I could have sworn there was one. Probably got confused by the presence of the arbitrary precision Integer type. Yeah appears to be missing.
@dnolen Did look at it but I have a ton of people with GLSL experience in my team so I didn't want to throw them off even more than I've already have by putting them on cljs.
Hi. I have included figwheel to an existing reagent app. Starting lein figwheel
works without errors. Sadly the init!
function is not called in my core.cljs. Any ideas what the reason could be? Thank you!
@nfisher I got it. I forgot to include my dev.cljs which calls the init! function. Thanky you!
can anyone point me to a recursive-macroexpand implementation? I need macroexpand which walks a form and applies macro-expansion to all nodes (top-bottom)
@darwin doesn’t macroexpand-all
exist?
oh it’s in clojure.walk
@anmonteiro thanks, I didn’t look into clojure.walk 🙂
that is how I would implement it, using clojure.walk, but didn’t want to reinvent the wheel 🙂
how I can get function name in macros?
@savelichalex what do you mean?
let's explain I have function (defn foo [])
and I want to get foo
@savelichalex this still isn’t enough information to know what you mean
no no, I don't know how calling this right
just when I create it through defn
this is called var
, right?
this discussion will be much simpler if you give some example simple macro that you are trying to write
Of course, just give me a sec
@dnolen a little snippet
@savelichalex https://github.com/clojure/clojurescript/blob/master/src/main/clojure/cljs/analyzer/api.cljc#L144
@savelichalex what about something like this?
https://github.com/binaryage/dirac/blob/master/src/automation/dirac/automation.clj#L43
in defscreen
you can call get-component-name
passing it (meta #'~screen-component)
and get-component-name
should be a normal function looking at the data and extracting name:
https://github.com/binaryage/dirac/blob/master/src/automation/dirac/automation/machinery.cljs#L64
ah maybe that’s maybe not what you wanted to do, my solution extract metadata to cljs land (to be used at runtime)
@darwin but I want to use get-component-name
in cljs code
now when I think about it more, your solution also extracts the var metadata to cljs (if ~(resolve-var &env component)
was correct), so if you are ok with that, you can replace ~(resolve-var &env component)
with #’~component
I believe
but ultimately you want to resolve it at compile-time I believe, so generated cljs code contains just the name baked-in
@darwin hm, i'm using it in runtime too. Can use explain what #'~
do please?
@savelichalex I can’t explain, it is just magic I use, my understanding is it that it gives you var-like thing for given symbol 🙂
@darwin heh, well, then I just remember this))
but if I understand right var is not working
oops)
I have done little clojure, so for me cljs is the standard, and clojure is divergent 😉
and those var-like structures are available only in macros, but nothing is stopping you “emit” that data to cljs side, to be used at runtime
ahah, great point!)
that is what we are doing there, but you must be careful, you don’t want to mindlessly dump whole compiler state into generated js 😉
I may be wrong of course, this is a bit blurry area for me, I used it only for test infrastructure, so I didn’t care that much
guys, I need help again) I use get-component-name
in function, that iterate through vector with map
and it's return local variable name. What I'm doing wrong?
@savelichalex show us the code
I choose @dnolan solution for macro
(defmacro get-component-name
[fn]
(-> (resolve &env fn) :name str))
in defscreen you have to extract metadata from original symbol used, and pass it down the pipe
Does this mean that I can't get real function name?
depends what do you mean by function name, AFAIK defn is just a sugar for (def … (fn …)), so your functions have technically no name
think about this:
`(defn a [] “I’m a”)
(def b a)`
what should (defscreen b …)
see as function name?
Looks like they see name of var b
Ok, this is mean that var is somehow "linked" with fn
Maybe I can save it to this fn
first time
And then use that saved value
@darwin what do you think, this is possible?
smth like in meta for this fn
Or I can create map with it in defscreen
and use then... 😄
@savelichalex it is possible to attach metadata to functions, I just tested it in planck
@darwin What about add, not create with meta
both things work, attaching meta to fn, will turn in into MetaFn
(implementation detail)
(alter-meta! #'foo assoc :test "test")
should work 🙂
@darwin thanks a lot!
Can someone help me diagnose how I'm using atoms wrong in clojurescript? The error is No protocol method IDeref.-deref defined for type cljs.core/PersistentArrayMap
, the line is https://github.com/mathpunk/anansi/blob/master/src/cljs/anansi/reading/app.cljs#L19
what's odd is, i was referencing this data just fine a moment ago, and i can't tell what's changed
thinking i might not understand when to clj->js and vice versa (if there is a vice versa)
i think you’re doing @data when data
looks like {:foo :bar}
rather than (atom {:foo :bar})
Let's suppose I'm about to make a spiffy CLJS webapp with a WebGL-based GUI. Is there a particular WebGL library that you, great CLJS community, are most fond of? I've taken a look at a handful, and Karsten Schmidt's http://thi.ng libs really stand out, but I worry about taking a dependency on something (his "geom" lib) that's prominently marked as "BETA"/pre-release, and has only seen a handful of updates in the past year. Thoughts of the wise Clojurians?
If the situation is dire, I'll just write the WebGL abstractions I need to make ends meet. But if there's a nice lib, I'd much rather benefit from the efforts of those who have made this journey before.
@rovanion was just in here showing https://github.com/Rovanion/webgl-clojurescript-tutorial
https://github.com/kovasb/gamma was mentioned as part of that discussion