nxproc: open source software
nxproc is a Tcl extension providing named arguments, and much more, for any user-defined command. The nxproc package works with TclOO classes and objects. nxconstructor and nxmethod share innovative features with nxproc—they're all "drop-in" replacements for the built-in commands.
Tcl programmers often encounter procs having numerous arguments—including with optional values, for example, when needing to enter configuration parameters. Such commands benefit the most from nxproc. Consider this proc:
Calling mytest could go something like:
As the number of arguments increase it gets harder to keep track of the order of inputs, and it gets tedious having to restate defaults when entering the last optional values. Much better to be able to do this:
Note that values for dn and ez don't need to be repeated—defaults are applied automatically. Furthermore, the order of options entered on the command-line doesn't matter, variables will still be set correctly.
Easy to use
nxproc is invoked as follows:
Named args have a type, set when the argument list is defined. There are four types: boolean, numeric, string or enumerated. (Enumerated means input values are restricted to predetermined values included in the enum list.). In the case of bool and enum, type designators are mandatory. The characters b, e, n, s are abbreviations for types. Values are type-checked against the argument's type on command creation and at runtime. This provides a very useful sanity check on input values, reducing errors and possibly improving performance.
The project documentation has detailed information about nxproc. Be sure to check it out!
The oowebtools project uses nxproc interface extensively.
Information and download
Binaries and source code are available here: Fossil repository
Direct link to the download page: Downloads
Installing and full documentation: Documentation