built-in shelf
current elements (of element-expression)?
current elements
gives you shelf-like access to the currently-opened elements of the
currently-active markup parser. Its functionality is limited, and users are encouraged to use elements
of
instead.
The items of the current elements
shelf are always unkeyed. The first item on the shelf, if any,
is always the document element, or outermost element of the currently-active parse. The last item on the shelf,
if any, is always the innermost element of the currently-active parse. current elements
cannot be
modified directly, since it is always under the control of the markup parser; in this sense, it behaves much like a read-only
shelf-class function.
current elements
can be used in many context where a shelf of type markup-element-event
is
expected. For example, it can be passed to a function:
define function f (read-only markup-element-event e) elsewhere element #implied f (current elements) ; ...
Similarly a snapshot of the current open element stack can be had by using copy
:
element #implied local markup-element-event e variable copy current elements to e ; ...
Since current elements
is read-only
, the above-example could not have used copy-clear
,
nor could the argument to the earlier function have been defined as modifiable
or write-only
.
current elements
can be used in the header of a repeat over
loop to iterate of the
open element stack, whereas the depth of the open element stack can be obtained using number of current
elements
.