• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
      • B*
        • B*-binders
          • ACL2::patbind-ret
          • ACL2::patbind-stobj-get
            • Patbind-match
            • Patbind-when
            • Patbind-assocs
            • Patbind-the
            • Patbind-nths*
            • Patbind-er
            • Patbind-nths
            • Patbind-macro
            • Patbind-fun
            • Patbind-faig
            • Patbind-run-when
            • Patbind-pattern
            • Patbind-mv
            • Patbind-list*
            • Patbind-list
            • Patbind-cmp
            • Patbind-with-stolen
            • Patbind-with-fast
            • Patbind-unless-casematch
            • Patbind-cons
            • Patbind-access
            • Patbind-extract-keyword-args
            • Patbind-run-unless
            • Patbind-free-on-exit
            • Patbind-unless
            • Patbind-local-stobjs
            • Patbind-if
            • Patbind-getargs
            • Patbind-run-if
            • Patbind-state-global
            • Patbind-vl-read-zip-header-ret
            • Patbind-test-glmc-interp-nonhyps-ret
            • Patbind-test-glmc-interp-hyps-ret
            • Patbind-glmc-generic-interp-nonhyps-ret
            • Patbind-glmc-generic-interp-hyps-ret
          • Def-b*-binder
        • Defunc
        • Fty
        • Apt
        • Std/util
        • Defdata
        • Defrstobj
        • Seq
        • Match-tree
        • Defrstobj
        • With-supporters
        • Def-partial-measure
        • Template-subst
        • Soft
        • Defthm-domain
        • Event-macros
        • Def-universal-equiv
        • Def-saved-obligs
        • With-supporters-after
        • Definec
        • Sig
        • Outer-local
        • Data-structures
      • ACL2
        • Theories
        • Rule-classes
        • Proof-builder
        • Recursion-and-induction
        • Hons-and-memoization
        • Events
        • Parallelism
        • History
        • Programming
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
          • Make-event
          • Defmacro
          • Untranslate-patterns
          • Tc
          • Trans*
          • Macro-aliases-table
          • Macro-args
          • Defabbrev
          • User-defined-functions-table
          • Trans
          • Untranslate-for-execution
          • Add-macro-fn
          • Check-vars-not-free
          • Safe-mode
          • Macro-libraries
            • B*
              • B*-binders
                • ACL2::patbind-ret
                • ACL2::patbind-stobj-get
                  • Patbind-match
                  • Patbind-when
                  • Patbind-assocs
                  • Patbind-the
                  • Patbind-nths*
                  • Patbind-er
                  • Patbind-nths
                  • Patbind-macro
                  • Patbind-fun
                  • Patbind-faig
                  • Patbind-run-when
                  • Patbind-pattern
                  • Patbind-mv
                  • Patbind-list*
                  • Patbind-list
                  • Patbind-cmp
                  • Patbind-with-stolen
                  • Patbind-with-fast
                  • Patbind-unless-casematch
                  • Patbind-cons
                  • Patbind-access
                  • Patbind-extract-keyword-args
                  • Patbind-run-unless
                  • Patbind-free-on-exit
                  • Patbind-unless
                  • Patbind-local-stobjs
                  • Patbind-if
                  • Patbind-getargs
                  • Patbind-run-if
                  • Patbind-state-global
                  • Patbind-vl-read-zip-header-ret
                  • Patbind-test-glmc-interp-nonhyps-ret
                  • Patbind-test-glmc-interp-hyps-ret
                  • Patbind-glmc-generic-interp-nonhyps-ret
                  • Patbind-glmc-generic-interp-hyps-ret
                • Def-b*-binder
              • Defunc
              • Fty
              • Apt
              • Std/util
              • Defdata
              • Defrstobj
              • Seq
              • Match-tree
              • Defrstobj
              • With-supporters
              • Def-partial-measure
              • Template-subst
              • Soft
              • Defthm-domain
              • Event-macros
              • Def-universal-equiv
              • Def-saved-obligs
              • With-supporters-after
              • Definec
              • Sig
              • Outer-local
              • Data-structures
            • Trans1
            • Defmacro-untouchable
            • Set-duplicate-keys-action
            • Add-macro-alias
            • Magic-macroexpand
            • Defmacroq
            • Trans!
            • Remove-macro-fn
            • Remove-macro-alias
            • Add-binop
            • Untrans-table
            • Trans*-
            • Remove-binop
            • Tcp
            • Tca
          • Interfacing-tools
        • Interfacing-tools
        • Hardware-verification
        • Software-verification
        • Math
        • Testing-utilities
      • B*-binders

      ACL2::patbind-stobj-get

      Syntactic sugar for using stobj-let to get some fields from a sub-stobj.

      This b* binder provides a way to code accesses to nested stobjs within a b* form, as an alternative to stobj-let. Here is an an example:

      (b* (((stobj-get data-obj child-stobj1) ;; extracted data and updated child stobjs
      
            ;; bindings for subform :
            ((child-stobj1 (child-field parent-stobj))
             (child-stobj2 (child-arr n parent-stobj)))
      
            ;; subform:
            (b* ((data (child-stobj2-data child-stobj2))
                 (child-stobj1 (update-child-stobj1-data newdata child-stobj1)))
               (mv data child-stobj1))))
        (mv data-obj parent-stobj))

      The above extracts child-stobj1 and child-stobj2 from parent-stobj and binds them while evaluating the subform, which extracts a (non-stobj) data object from child-stobj2 and updates a field of child-stobj1 with some new data. We then return the data object and (implicitly) the parent-stobj, which must be returned since one of its child stobjs was updated. More explicitly, this macroexpands (more or less) to the following:

      (b* (((mv data-obj parent-stobj) ;; returned values: data and modified parent stobj
            (stobj-let ((child-stobj1 (child-field parent-stobj))
                        (child-stobj2 (child-arr n parent-stobj))) ;; bindings
                       (data-obj child-stobj1) ;; producer variables
                       ;; subform:
                       (b* ((data (child-stobj2-data child-stobj2))
                            (child-stobj1 (update-child-stobj1-data newdata child-stobj1)))
                         (mv data child-stobj1))
                       ;; returned values:
                       (mv data-obj parent-stobj))))
        (mv data-obj parent-stobj))

      The general form of a stobj-get binding is:

      (b* (...
           ((stobj-get VARS)
            BINDINGS
            . SUBFORMS)
           ...)
       ...)

      BINDINGS are bindings of stobj names to stobj accessors. SUBFORMS are the forms that are evaluated under the bindings, in an implicit progn (so all but the last are just for side effects). The VARS correspond to the values returned by the last subform.