Overview
| Comment: | 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`. |
|---|---|
| Timelines: | family | ancestors | descendants | both | tip-764_tcl90 |
| Files: | files | file ages | folders |
| SHA3-256: |
71c944ab7a99c307958f624f29636e6b |
| User & Date: | Florentis on 2026-11-05 11:19:41.532 |
| Other Links: | branch diff | manifest | tags |
Context
|
2026-11-05
| ||
| 13:22 | v16r 1. Typed procedures: added syntax for configuring the unfolding of product and sum types: the p... check-in: 2ce9df4c51 user: Florentis tags: tip-764_tcl90 | |
| 11:19 | v16q (options and flags): only tclTypes.c and tclTypeParse.c are modified. A group is defined usi... check-in: 71c944ab7a user: Florentis tags: tip-764_tcl90 | |
| 09:32 | v16p: product field is optional if all its subfields have a default value; messages without a produc... check-in: 5e98c7c6b0 user: Florentis tags: tip-764_tcl90 | |
Changes
Modified typeparse/REPRISE.md
from [97f2680152]
to [e69cf69af9].
[diff]
Modified typeparse/VERSION
from [7801b7fd53]
to [1495f943bb].
[diff]
Modified typeparse/doc/764.md
from [bded5ecc4b]
to [fa7b4ec6c2].
[diff]
Modified typeparse/doc/ANNOTATIONS.fr.md
from [702bbfcd21]
to [d61369a329].
[diff]
Added typeparse/exemples/bench_options.tcl version [3bb620946e].
Modified typeparse/noyau/LISEZMOI.md
from [c934710c4d]
to [8af3a8aff2].
[diff]
Modified typeparse/tclTypeParse.c
from [d209cd47d7]
to [9a850b35a8].
[diff]
Modified typeparse/tclTypes.c
from [ef1bf71e38]
to [9f8c672e6e].
[diff]
Modified typeparse/tclTypes.h
from [162776cf9e]
to [1095985218].
[diff]
Added typeparse/tests_tclsh/t97_options.out version [0f670b3a37].
Added typeparse/tests_tclsh/t97_options.tcl version [e4177ecbc2].