Create a new stobj that is
If you want to write an algorithm that operates on two bit arrays, you might
clone the bitarr to get a second stobj,
(defstobj-clone bitarr2 bitarr :suffix "2")
This introduces:
Usually you can just ignore these new functions. They are added only because of the way that ACL2 stobj definition works and, strictly speaking, are not really necessary for anything else because you can still use the original stobj's functions on the new stobj.
Ignoring the new functions is particularly useful when you have already
built up more complex functionality on top of a stobj. That is, if you've
implemented functions like
On the other hand, it may occasionally be useful for code clarity to rename
the new functions in some semantically meaningful way. For instance, if your
cloned bit array will be used as a seen table, it may be convenient to use
operations like
To support using such semantically meaningful names,
(defstobj-clone fancy-bitarr bitarr :strsubst (("GET" . "FETCH") ;; Substring replacements to make ("SET" . "INSTALL")) ;; (capitalized per symbol names) :prefix "MY-" ;; Name prefix to add :suffix "-FOR-JUSTICE" ;; Name suffix to add :pkg acl2::rewrite ;; Package for new symbols ;; default: new stobj name )
The result is to define new analogues of the
bitarrp --> fancy-bitarrp create-bitarr --> create-fancy-bitarr bits-length --> my-bits-length-for-justice get-bit --> my-fetch-bit-for-justice set-bit --> my-install-bit-for-justice resize-bits --> my-resize-bits-for-justice
For an abstract stobj, the accessors/updaters are known as "exports".
Another way to specifying their names in the new stobj is to provide the
(defstobj-clone xx-bitarr bitarr :exports (xx-size xx-nth !xx-nth xx-resize))
Defines a new
bitarrp --> xx-bitarrp create-bitarr --> create-xx-bitarr bits-length --> xx-size get-bit --> xx-nth set-bit --> !xx-nth resize-bits --> xx-resize