Add a global stobj with a given name
See stobj for background on stobjs, and see defstobj and defabsstobj for further background.
We start with the General Form and an Example Form, which are followed by discussions of global stobjs and the effect of this utility.
General Form: (add-global-stobj x state)
where
Example Form: (add-global-stobj 'st state) ; st non-global from defstobj or defabsstobj
By default,
ACL2 !>(defstobj st fld) Summary Form: ( DEFSTOBJ ST ...) Rules: NIL Time: 0.02 seconds (prove: 0.00, print: 0.00, other: 0.02) ST ACL2 !>st ; global stobj for the name, ST <st> ACL2 !>(fld st) NIL ACL2 !>(update-fld 3 st) <st> ACL2 !>(fld st) 3 ACL2 !>
However, the following log shows that we can introduce a stobj without
creating a global stobj, by using the keyword value
ACL2 !>(defstobj st2 fld2 :non-executable t) Summary Form: ( DEFSTOBJ ST2 ...) Rules: NIL Time: 0.02 seconds (prove: 0.00, print: 0.00, other: 0.02) ST2 ACL2 !>(fld2 st2) ACL2 Error [Evaluation] in TOP-LEVEL: Unbound var ST2. Note that ST2 is a non-executable stobj. ACL2 !>
The function
ACL2 !>(add-global-stobj 'st2 state) ST2 ACL2 !>(fld2 st2) NIL ACL2 !>(update-fld2 3 st2) <st2> ACL2 !>(fld2 st2) 3 ACL2 !>
The function
ACL2 !>(remove-global-stobj 'st2 state) ST2 ACL2 !>(fld2 st2) ACL2 Error [Evaluation] in TOP-LEVEL: Unbound var ST2. Note that ST2 is a non-executable stobj. ACL2 !>
If we remove a global stobj, as shown just above, and then add the corresponding global stobj, we get a fresh copy of that stobj; all previous updates are discarded.
ACL2 !>(add-global-stobj 'st2 state) ST2 ACL2 !>(fld2 st2) NIL ACL2 !>