;; open upvalue get
(setq res-1
      (let (a 123)
        ((lambda (b) (+ a b)) 321)
        ))
;; shared open upvalue get
(setq res-2
      (let (a 123)
        (let
          (
           x ((lambda (b) (+ a b) (+ a b)) 321)
           y ((lambda (b) (+ a b) (* a b)) 2)
           )
          (+ x y)
          )
        )
      )
;; closed upvalue get
(setq func-0 (let (a 123) (lambda (b) (+ a b))))

;; open upvalue set
(setq res-3
      (let (a 123)
        ((lambda (b) (setq a b)) 321)
        a
        )
      )
;; shared open upvalue set
(setq res-4
      (let (a 123)
        (let (
              funcs (list
                      (lambda () (setq a 1))
                      (lambda () (setq a (+ a 1)))
                      (lambda () (setq a (+ a 2)))
                      )
              )
          (while (not (nil? funcs))
            ((car funcs))
            (setq funcs (cdr funcs))
            )

          a
          )
        )
      )
;; closed upvalue set
(setq func-1 (let (a 123) (lambda (b) (setq a (+ a b)) a)))

(assert (= 444 res-1))
(assert (= 690 res-2))
(assert (= 444 (func-0 321)))
(assert (= 321 res-3))
(assert (= 4 res-4))
(assert (= 444 (func-1 321)))
