rcf icon indicating copy to clipboard operation
rcf copied to clipboard

merely inspecting *1 *2 *3 should not affect history

Open dustingetz opened this issue 3 years ago • 5 comments

(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)))))
  )

dustingetz avatar Jul 25 '21 16:07 dustingetz

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)))))))

ggeoffrey avatar Jul 27 '21 17:07 ggeoffrey

No it breaks the natural REPL experience

dustingetz avatar Jul 27 '21 18:07 dustingetz

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.

ggeoffrey avatar Jul 27 '21 18:07 ggeoffrey

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)

dustingetz avatar Apr 06 '22 14:04 dustingetz

Latest RCF (master, not stable) does not comply with this requirement. It behaves as the REPL.

ggeoffrey avatar Apr 18 '22 09:04 ggeoffrey