mirror of
https://github.com/janet-lang/janet
synced 2025-10-21 18:57:41 +00:00
Make top level vars reuse ref cell when redefined at the top level.
This improves the repl experience while not messing with existing code very much, if at all.
This commit is contained in:
@@ -302,17 +302,7 @@
|
||||
(assert (= 1 (staticdef1-inc)) "before redefinition without :redef")
|
||||
(def staticdef1 1)
|
||||
(assert (= 1 (staticdef1-inc)) "after redefinition without :redef")
|
||||
(def dynamicdef1 :redef 0)
|
||||
(defn dynamicdef1-inc [] (+ 1 dynamicdef1))
|
||||
(assert (= 1 (dynamicdef1-inc)) "before redefinition with :redef")
|
||||
(def dynamicdef1 :redef 1)
|
||||
(assert (= 2 (dynamicdef1-inc)) "after redefinition with :redef")
|
||||
(setdyn :redef true)
|
||||
(def staticdef2 {:redef false} 0)
|
||||
(defn staticdef2-inc [] (+ 1 staticdef2))
|
||||
(assert (= 1 (staticdef2-inc)) "before redefinition with :redef false")
|
||||
(def staticdef2 {:redef false} 1)
|
||||
(assert (= 1 (staticdef2-inc)) "after redefinition with :redef false")
|
||||
(def dynamicdef2 0)
|
||||
(defn dynamicdef2-inc [] (+ 1 dynamicdef2))
|
||||
(assert (= 1 (dynamicdef2-inc)) "before redefinition with dyn :redefs")
|
||||
|
Reference in New Issue
Block a user