jank-lang / jank

The native Clojure dialect hosted on LLVM
https://jank-lang.org
Mozilla Public License 2.0
1.7k stars 50 forks source link

Add support for delay #123

Closed jianlingzhong closed 2 weeks ago

jianlingzhong commented 3 weeks ago

Still a draft. Needs more work:

❯ build/jank repl
Bottom of clojure.core
> (def my-delay (delay (println "did some work")))
did some work
#'clojure.core/my-delay
> (force my-delay)
Unknown exception thrown
❯ build/jank repl
Bottom of clojure.core
> (def my-delay (delay (+ 4 5)))
#'clojure.core/my-delay
> (println my-delay)
delay@0x1170c0d80
nil
> (force my-delay)
Unknown exception thrown
jeaye commented 2 weeks ago

The changes look great, @jianlingzhong! Please format all of the C++ with clang-format from the build/llvm-install dir before we merge.

jianlingzhong commented 2 weeks ago

Things should work now:

❯ build/jank repl
Bottom of clojure.core
> (def d (delay (println "test")))
#'clojure.core/d
> d
delay@0x1173924d0
> (deref d)
test
nil
> (deref d)
nil
> (def d (delay (println "test")))
#'clojure.core/d
> (force d)
test
nil
> (force d)
nil
> (force 42)
42
> 

Thanks @jeaye !

jianlingzhong commented 2 weeks ago

The changes look great, @jianlingzhong! Please format all of the C++ with clang-format from the build/llvm-install dir before we merge.

Done!

jeaye commented 2 weeks ago

Nice job!