File
typeparse/VERSION
— part of check-in
[71c944ab7a]
at
2026-11-05 11:19:41
on branch tip-764_tcl90
— v16q (options and flags):
only tclTypes.c and tclTypeParse.c are modified.
A group is defined using the syntax {T}-o
tcl
proc {list}trier {
{flag}-decreasing;
{int}-index ?= -1;
{"ascii", "dictionary", "integer", {string}command}-mode ?= ascii;
{list}l
} {...}
trier -dec -index 1 -integer $L
Syntax and invocation
A field denoted as -x is an option, provided at the beginning of the call. Options end at the first word that is not an option, at --, or at a negative number (e.g., -5).
Prefixes: a unique prefix is sufficient (e.g., -dec). The corresponding local variable omits the leading hyphen.
Flags: {flag}-x results in a local variable set to 1 or 0. `flag` is a new, predefined type.
Options with values: {T}-x ?= v, where the value is validated. If the option is omitted and no default is provided, the local variable is not created.
Exclusive options (a sum type)
Each variant acts as an option: -ascii (a literal, value-less option), -command cmd (a typed variant with a value), or -mode ascii.
The local variable `mode` receives the name of the chosen variant, while the local variable `command` receives its associated value.
Selecting two different variants triggers an error: "options -ascii and -integer are exclusive." The default value must specify one of the variants.
Dependent options (a product type)
Example: {"flat", {{string}cmd; {int}-depth ?= 1; {flag}-follow}command}-mode.
The invocation -command ls -depth 3 -follow is accepted, whereas -depth on its own results in the error: "option -depth requires -command." Group
{triopts}-o: the `triopts` fields represent the available options—including variations of a "sum" field—where `o` is a specific `triopts` value.
A single group can be used for multiple procedures.
Messages and introspection
Error messages follow the Tcl style: e.g., `bad option "-zz": must be -ascii, -command, …`, `ambiguous option "-d": …`, or `option "-index" needs a value`.
The usage message lists the available options: `?-decreasing? ?-index value? ?-ascii|-dictionary|-integer|-command value?`.
`info args` and `info default` recognize these options; for a flag (boolean option), `info default` returns `0`.
(user:
Florentis,
size: 5)
[annotate]
[blame][check-ins using]