Bind state global variables
See programming-with-state for requisite background on programming with the ACL2 state.
Example Forms: (state-global-let* ((inhibit-output-lst *valid-output-names*)) (thm (equal x x))) (state-global-let* ((fmt-hard-right-margin 1000 set-fmt-hard-right-margin) (fmt-soft-right-margin 1000 set-fmt-soft-right-margin)) (mini-proveall)) General Form: (state-global-let* ((var1 form1) ; or (var1 form1 set-var1) ... (vark formk) ; or (vark formk set-vark) ) body)
where: each
The restoration is guaranteed even in the face of aborts. The ``bound'' variables may initially be unbound in state and restoration means to make them unbound again.
Still referring to the General Form above, we next discuss how the values
are set and restored. Let
Note that the scope of the bindings of a
ACL2 !>(state-global-let* ((print-base 16 set-print-base) (print-radix t set-print-radix)) (mv nil 10 state)) 10 ACL2 !>
Why wasn't the result printed as
ACL2 !>(state-global-let* ((print-base 16 set-print-base) (print-radix t set-print-radix)) (pprogn (fms "~x0~%" (list (cons #\0 10)) *standard-co* state nil) (mv nil 10 state))) #xA 10 ACL2 !>
Finally, as promised above, here is the definition of the constant that maps certain built-in untouchable variables to setters.
Definition:
(defconst *state-global-let*-untouchable-alist* '((abbrev-evisc-tuple . set-abbrev-evisc-tuple-state) (compiler-enabled . set-compiler-enabled) (current-package . set-current-package-state) (fmt-hard-right-margin . set-fmt-hard-right-margin) (fmt-soft-right-margin . set-fmt-soft-right-margin) (gag-mode-evisc-tuple . set-gag-mode-evisc-tuple-state) (inhibit-output-lst . set-inhibit-output-lst-state) (inhibited-summary-types . set-inhibited-summary-types-state) (ld-evisc-tuple . set-ld-evisc-tuple-state) (ppr-flat-right-margin . set-ppr-flat-right-margin) (print-base . set-print-base) (print-case . set-print-case) (print-length . set-print-length) (print-level . set-print-level) (print-lines . set-print-lines) (print-right-margin . set-print-right-margin) (proofs-co . set-proofs-co-state) (serialize-character . set-serialize-character) (serialize-character-system . set-serialize-character-system) (standard-co . set-standard-co-state) (temp-touchable-fns . set-temp-touchable-fns) (temp-touchable-vars . set-temp-touchable-vars) (term-evisc-tuple . set-term-evisc-tuple-state)))