• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
        • State
        • Mutual-recursion
        • Memoize
        • Mbe
        • Io
        • Defpkg
        • Apply$
        • Loop$
        • Programming-with-state
          • Error-triple
          • Cbd
          • State-global-let*
          • Last-prover-steps
          • @
          • Assign
          • Read-run-time
          • Canonical-pathname
          • F-put-global
          • Unsound-eval
          • Setenv$
          • Er-progn
          • Read-ACL2-oracle
          • With-live-state
            • F-get-global
            • Getenv$
            • Pprogn
            • Get-real-time
            • Makunbound-global
            • Get-cpu-time
            • F-boundp-global
            • Probe-file
          • Arrays
          • Characters
          • Time$
          • Defmacro
          • Loop$-primer
          • Fast-alists
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Efficiency
          • Irrelevant-formals
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Programming-with-state
    • ACL2-built-ins

    With-live-state

    Allow a reference to state in raw Lisp

    The macro with-live-state is an advanced feature that very few users will need (basically, only system hackers). Indeed, it is essentially untouchable, defined with defmacro-untouchable; remove-untouchable for how to enable calling with-live-state in the ACL2 loop.

    Example Form:
    (with-live-state (assign y 3))
    
    General form:
    (with-live-state form)

    where form is an arbitrary form with a free reference to the variable state.

    Logically, (with-live-state FORM) macroexpands to FORM. However, in raw Lisp it expands to:

    (let ((state *the-live-state*))
      FORM)

    If a form that mentions the variable state might be executed in raw Lisp — that is, either outside the ACL2 loop or in raw mode (see set-raw-mode) — then the surrounding the form with with-live-state as shown above can avoid potential warnings or (much less likely) errors. Note however that if state is lexically bound to a state other than the usual ``live'' state, surprising behavior may occur when evaluating a call of with-live-state in raw Lisp or raw mode (either directly by evaluation or at compile time), because with-live-state will override that lexical binding of state by a lexical binding of state to the usual ``live'' state.