Fork me on GitHub
#jaunt
<
2016-04-07
>
arrdem18:04:05

@bronsa: so I've been digging on that fn .withMeta thing you pointed out yesterday, and I'm pretty much convinced that the AFn.withMeta is dead code.

arrdem18:04:35

ObjExpr.compile already creates .withMeta() and .meta() implementations unconditionally both for deftypes and fns. Demo of this behavior above. If the default abstract class implementation were running, then that vary-meta invocation would have returned a different class type.

bronsa18:04:26

don't think that's true

bronsa18:04:33

IIRC it does that only for reify

bronsa18:04:48

ompiled from "test.clj"
public final class test$fn__18 extends clojure.lang.AFunction {
  public test$fn__18();
    Code:
       0: aload_0
       1: invokespecial #9                  // Method clojure/lang/AFunction."<init>":()V
       4: return

  public static java.lang.Object invokeStatic();
    Code:
       0: aconst_null
       1: areturn

  public java.lang.Object invoke();
    Code:
       0: invokestatic  #14                 // Method invokeStatic:()Ljava/lang/Object;
       3: areturn

  public static {};
    Code:
       0: return
}

bronsa18:04:52

well, is that jaunt or clojure? simple_smile

bronsa18:04:56

I have no idea what changes you made

bronsa18:04:04

but in clojure that's definitely not the case

arrdem18:04:16

That's Jaunt. I haven't deliberately changed anything there yet...

arrdem18:04:54

may the Old Ones smile on you

bronsa18:04:23

this is disgusting

bronsa18:04:39

withMeta is only emitted if the function already has metadata at compile-time

bronsa18:04:51

e.g. ^:foo (fn []) will have it, (fn []) won't

bronsa18:04:04

reason why you're seeing it everywhere in Jaunt is because you're attaching :uses etc

arrdem18:04:30

Right. Because that's how it makes the MetaExpr(FnExpr, MapExpr) work.

arrdem18:04:44

I agree that should be unconditional.

bronsa18:04:56

I guess just make supportsMeta return true in FnExpr rather than checking for hasMeta then

arrdem18:04:09

The other thing I want to do here is ditch that MetaExpr, metadata should be in a Fn's <cinit>

arrdem18:04:43

Eh.... that's actually not critical. Whatever.

bronsa18:04:16

@arrdem: or maybe even make supportsMeta test hasMeta || hasPrimSigs

bronsa18:04:34

that's the only case where that makes a difference

bronsa18:04:46

or not, if you want to avoid forcing the applyTo path I guess

arrdem18:04:56

Eh. I'm content to hard code supportsMeta true, right and avoid the applyTo path.

arrdem18:04:20

Two line change and a bunch of deletions. Best kinda patch.

bronsa18:04:31

downside is every fn is now ~300bytes heavier

arrdem18:04:05

Not even...

arrdem18:04:47

Derp. I didn't read carefully. You were dead on.

arrdem18:04:40

Eh. The price of sanity. I'm willing to pay it and after all this is my sandbox 😛