Fork me on GitHub
#cljs-dev
<
2018-10-25
>
mfikes12:10:57

Small bit of progress on release-blocker https://dev.clojure.org/jira/browse/CLJS-2793 ... the experimental patch in it also fixes https://dev.clojure.org/jira/browse/CLJS-2942

dnolen12:10:50

oh whoa, cool, will take a look at that later

mfikes12:10:40

Looking again at the experimental patch, it probably fails under advanced because it does

(gobj/get f (str "cljs$core$IFn$_invoke$arity$" ...
(Dunno why I hadn't noticed that earlier.)

mfikes12:10:43

I probably wrote it that way to make it dynamic... (it is adding the arg count to the end of that str call)

mfikes12:10:53

Maybe fixable with a macro...

dnolen12:10:01

@mfikes what about goog.reflect?

mfikes12:10:26

Hmm. I'm not familiar with that API, but will take a look.

dnolen12:10:04

I believe it lets you get at the renamed properties at runtime using the original name

mfikes12:10:20

Oh, that's exactly what we need here

mfikes12:10:24

Hmm. It appears empirically that you must past a compile-time constant string to goog.reflect/objectProperty, otherwise Closure compilation fails. This seems to make sense to me in that it can't do anything with runtime values.

mfikes12:10:03

I'll try a different experiment that simply unrolls regular property access out to arity 20 or so

dnolen12:10:45

@mfikes you could make a lookup table though for the properties you need right?

dnolen12:10:52

like a map

mfikes12:10:59

Yeah, thinking about using case for quick dispatch.

dnolen12:10:09

you don't need that many

mfikes12:10:32

Yeah, I was just going to write a big case out to 20

dnolen12:10:35

sure, was just pointing out that goog.reflect can work if your constants are bounded

mfikes12:10:38

or whatever the stopping point needs to be

dnolen12:10:03

(not saying it's the right way for this problem, just if it seemed like a good fit etc)

mfikes12:10:07

An expansion of this fn is what I'm trying now. Perhaps it could be improved, but it should work

(defn- get-arity-dispatch [f n]
  (case n
    0 (.-cljs$core$IFn$_invoke$arity$0 f)
    1 (.-cljs$core$IFn$_invoke$arity$1 f)))

mfikes12:10:43

A macro could write that fn for me, but it is easy enough to just write it by hand for now 🙂

mfikes12:10:41

Hrm. That does't lead to things passing under :advanced either. Will hack on this later.

mfikes16:10:50

Added a bit more to https://dev.clojure.org/jira/browse/CLJS-2793 For me at least, the stuff in that ticket gets things closer to working (but without fully working under :advanced) without having a true comprehension on how things are subtly derailing.

thheller22:10:02

nvm ... static-fns already does that