Fork me on GitHub
#cljs-dev
<
2017-05-20
>
rauh15:05:00

So working on CLJS-2041... If I emit (f.IFn$blah || f)(the_arg) it somehow loses this context (sometimes). However (f.IFn$blah ? f.IFn$blah(the_arg) : f(the_arg)) works just fine. Just curious if there are any JS cracks that know why?

rauh16:05:09

Welp, learnt some new JS:

(js* "(~{})(~{})"
     (.-cljs$core$IFn$_invoke$arity$1 :a)
     {:a 2})
;; => works

(js* "(~{} || 0)(~{})"
     (.-cljs$core$IFn$_invoke$arity$1 :a)
     {:a 2})
;; => null, loses this

dnolen16:05:02

sidenote - I would not change the codegen pattern here unless you have a really good reason

dnolen16:05:23

accessing a property will not preserve this

rauh16:05:34

Yeah, not gonna change it, it was just an idea I wanted to try. Would've been nice, but probably even much slower.

rauh16:05:08

Right now it'll double check the property with static-fns.

rauh17:05:19

New patch submitted for 2041.