Play with circular refs around closures

This commit is contained in:
Scott Richmond 2022-05-19 16:17:30 -04:00
parent f419c390af
commit 959927f7ce

View File

@ -405,37 +405,9 @@
(def source "
fn swap! (rf, f) -> {
let val = deref (rf)
let new = f (val)
set! (rf, new)
}
let foo = :bar
let counter = {
ref i = 0
fn next () -> {
let n = deref (i)
if eq (n, 3)
then (:done, nil)
else {
swap! (i, inc)
(:value, n)
}
}
ns Counter {next}
}
print (counter :next ())
print (counter :next ())
print (counter :next ())
print (counter :next ())
print (counter :next ())
let foo = nil
counter
fn foof () -> panic! (:oops)
")