summaryrefslogtreecommitdiffstats
path: root/vm.c
diff options
context:
space:
mode:
authorKaz Kyheku <kaz@kylheku.com>2020-03-06 21:07:46 -0800
committerKaz Kylheku <kaz@kylheku.com>2020-03-06 21:07:46 -0800
commit8bb9388feeaa9f981862cab608166105ed31a03c (patch)
tree53a372d7687d2eae16e866c55c7bc803ece3dbe3 /vm.c
parenta7f62122d54d2d70e2ae1afda9b27df969f75e5e (diff)
downloadtxr-8bb9388feeaa9f981862cab608166105ed31a03c.tar.gz
txr-8bb9388feeaa9f981862cab608166105ed31a03c.tar.bz2
txr-8bb9388feeaa9f981862cab608166105ed31a03c.zip
getopts: new feature: cumulative options.
An option declared as (cumul <type>) indicates that it is of type <type>, and that multiple occurrences of the option produce values that are accumulated into a list. The accumulation is in reverse order: the rightmost occurrence ends up the first in the list. * lisplib.c (getopts_set_entries): Add cumul to list of interned symbols, so that the getopts.tl code isn't mistakenly working with sys:cumul. * share/txr/stdlib/getopts.tl (opt-parsed): New slot, cumul. (opt-desc basic-type p, opt-desc list-type-p, opt-desc cumul-type-p): New methods. (opt-desc check): Rework type validity check using the new methods. (opt-parsed convert-type): Support 'cumul type by instantiating an opt-parsed object for the wrapped type, and stealing its converted argument into the current object, and setting the cumul flag. (opts add-opt, option-base add-opt): Support options that have the cumul flag set by accumulating list values. The code is different due to different amounts of encapsulation. The opts structure stores the raw opt-parsed objects, whereas option-base just takes the decoded values. (opthelp): Parse through the (cumul ...) type syntax, so cumulative options are printed in the help text the same way as if they were non-cumulative. * txr.1: Documented.
Diffstat (limited to 'vm.c')
0 files changed, 0 insertions, 0 deletions