JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in
# By default, top level defs perform better: (defn let-sum [] (let [a 1 b 2 c 3] (+ a b c))) (def a 1) (def b 2) (def c 3) (defn top-def-sum [] (+ a b c)) (disasm let-sum) # (ldi 0 1) (ldi 1 2) (ldi 2 3) (add 3 0 1) (add 3 3 2) (disasm top-def-sum) # (ldi 0 1) (addim 1 0 2) (addim 1 1 3) # But with *optimize* level 3, they are both better # n.b. func must be (re)defined after *optimize* is set (setdyn *optimize* 3) (defn let-sum [] (let [a 1 b 2 c 3] (+ a b c))) (defn top-def-sum [] (+ a b c)) (disasm let-sum) # (ldi 0 6) (disasm top-def-sum) # (ldi 0 6) # currently, implemented optimizations are mostly in 1 and 2