Skip to content

Instantly share code, notes, and snippets.

@mfikes
Created August 14, 2017 14:19
Embed
What would you like to do?

Original code:

(ns foo.core
  (:require [goog.object :as gobj]))

(defn f []
  (.call (fn []
         (prn 1 (aget (js-this) "greeting"))
         (prn 2 (gobj/get (js-this) "greeting"))
         (this-as this
           (prn 3 (aget this "greeting")))
         (this-as this
           (prn 4 (gobj/get this "greeting"))))
       #js {:greeting "Hello"}))

With :static-fns false

function foo$core$f() {
  return function() {
    cljs.core.prn.call(null, 1, this["greeting"]);

    cljs.core.prn.call(null, 2, goog.object.get(this, "greeting"));

    var this_22 = this;
    cljs.core.prn.call(null, 3, this_22["greeting"]);

    var this$ = this;
    return cljs.core.prn.call(null, 4, goog.object.get(this$, "greeting"));
  }.call({ greeting: "Hello" });
}

With :static-fns true

function foo$core$f() {
  return function() {
    cljs.core.prn.cljs$core$IFn$_invoke$arity$variadic(
      cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([1, this["greeting"]], 0)
    );

    cljs.core.prn.cljs$core$IFn$_invoke$arity$variadic(
      cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(
        [
          2,
          (function() {
            var G__22 = this;
            var G__23 = "greeting";
            return goog.object.get(G__22, G__23);
          })()
        ],
        0
      )
    );

    var this_24 = this;
    cljs.core.prn.cljs$core$IFn$_invoke$arity$variadic(
      cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(
        [3, this_24["greeting"]],
        0
      )
    );

    var this$ = this;
    return cljs.core.prn.cljs$core$IFn$_invoke$arity$variadic(
      cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(
        [4, goog.object.get(this$, "greeting")],
        0
      )
    );
  }.call({ greeting: "Hello" });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment