rcf
rcf copied to clipboard
merely inspecting *1 *2 *3 should not affect history
(tests
:foo
*1 := :foo) ; pass
(tests
:foo := :foo
*1 := :foo) ; fail, imo should pass
(tests
(inc 1)
:= 2
(dec *1) ; example usage (currently fails)
:= 1)
(tests ; real-world usage
(analyze {} '(+ 2 3))
:= [[[:apply [:global :clojure.core/+] [:literal 2] [:literal 3]]]
[[:literal nil]]]
(emit (comp symbol str) (first *1)) ; first says – ignore remote part, consider local part only
:= `(r/peer 0 0 0 0
(fn [~'context]
(do (m/latest u/call (r/steady +) (r/steady '2) (r/steady '3)))))
)
Would let
be enough?
(tests
(let [a (inc 1)]
a := 2
(dec a) := 1))
(tests
(let [a (analyze {} '(+ 2 3))]
a := [[[:apply [:global :clojure.core/+] [:literal 2] [:literal 3]]]
[[:literal nil]]]
(emit (comp symbol str) a) ; first says – ignore remote part, consider local part only
:= `(r/peer 0 0 0 0
(fn [~'context]
(do (m/latest u/call (r/steady +) (r/steady '2) (r/steady '3)))))))
No it breaks the natural REPL experience
For now, *1
refers to the result of the previous effect. Assertions are not considered effects. Which means assertions don’t introduce sequential dependencies.
If it was, which value should be bound to *1
?
In case of a successful assertion, it could be either one of LHS or RHS, as shown in your example.
But what if LHS and RHS don’t unify?
Should LHS be bound to *1
?
- RHS?
-
false
? - ::nothing (or similar)?
I would say either:
-
LHS
(propagate the actual result), potentially causing cascading errors, - ::nothing, either stopping assertions or willingly cause a cascade of unambiguous errors.
Better example:
(tests
"REPL bindings work"
(keyword "a") := :a
(keyword "b") := :b
(keyword "c") := :c
*1 := :c
*2 := :b
*3 := :a
*1 := :c ; inspecting history does not affect history
(keyword "d") := :d
*1 := :d
*2 := :c
*3 := :b
(symbol *2) := 'c ; this does affect history
(symbol *2) := 'd)
Latest RCF (master, not stable) does not comply with this requirement. It behaves as the REPL.