Next: Type Keywords, Previous: Composite Types, Up: Customization Types [Contents][Index]
The :inline
feature lets you splice a variable number of
elements into the middle of a list
or vector
customization type. You use it by adding :inline t
to a type
specification which is contained in a list
or vector
specification.
Normally, each entry in a list
or vector
type
specification describes a single element type. But when an entry
contains :inline t
, the value it matches is merged directly
into the containing sequence. For example, if the entry matches a
list with three elements, those become three elements of the overall
sequence. This is analogous to ‘,@’ in a backquote construct
(see Backquote).
For example, to specify a list whose first element must be baz
and whose remaining arguments should be zero or more of foo
and
bar
, use this customization type:
(list (const baz) (set :inline t (const foo) (const bar)))
This matches values such as (baz)
, (baz foo)
, (baz bar)
and (baz foo bar)
.
When the element-type is a choice
, you use :inline
not
in the choice
itself, but in (some of) the alternatives of the
choice
. For example, to match a list which must start with a
file name, followed either by the symbol t
or two strings, use
this customization type:
(list file (choice (const t) (list :inline t string string)))
If the user chooses the first alternative in the choice, then the
overall list has two elements and the second element is t
. If
the user chooses the second alternative, then the overall list has three
elements and the second and third must be strings.
Next: Type Keywords, Previous: Composite Types, Up: Customization Types [Contents][Index]