SimpleProc v1.0 

 The Simple Development Library procedures with extended argument syntax 

Project: the Simple Development Library.

Table of contents

1. Package description
   1.1 Overview
   1.2 Usage
   1.3 Examples
   1.4 History
   1.5 Copyright
2. Package public API
   2.1 Types
      2.1.1 extendedarg
      2.1.2 canonicalarg
   2.2 Options
      2.2.1 -checktype
      2.2.2 -afterflags
   2.3 Namespaces
   2.4 Commands
      2.4.1 ::Simple::Argument::check-type args
      2.4.2 ::Simple::Argument::information choices procedure argument
      2.4.3 ::Simple::Argument::information default procedure argument
      2.4.4 ::Simple::Argument::information defaultgiven procedure argument
      2.4.5 ::Simple::Argument::information description procedure argument
      2.4.6 ::Simple::Argument::information flaggiven flag
      2.4.7 ::Simple::Argument::information givenflags
      2.4.8 ::Simple::Argument::information isdefault argument
      2.4.9 ::Simple::Argument::information type procedure argument
      2.4.10 ::Simple::Proc::cget ?-checktype? ?-afterflags?
      2.4.11 ::Simple::Proc::configure ?-checktype extbool? ?-afterflags integer?
      2.4.12 proc-ext ?-parseflags extbool? ?-checktype extbool? procedure arguments body
      2.4.13 ::Simple::Proc::delete procedure
      2.4.14 ::Simple::Proc::information access procedure
      2.4.15 ::Simple::Proc::information alias procedure
      2.4.16 ::Simple::Proc::information args procedure
      2.4.17 ::Simple::Proc::information arguments procedure
      2.4.18 ::Simple::Proc::information body procedure
      2.4.19 ::Simple::Proc::information caller ?levels?
      2.4.20 ::Simple::Proc::information checktype procedure
      2.4.21 ::Simple::Proc::information exists procedure
      2.4.22 ::Simple::Proc::information isextended procedure
      2.4.23 ::Simple::Proc::information issubcommand procedure
      2.4.24 ::Simple::Proc::information metadata procedure
      2.4.25 ::Simple::Proc::information parseflags procedure
      2.4.26 ::Simple::Proc::information runtimeparsing procedure
      2.4.27 ::Simple::Proc::information subcommands command
      2.4.28 ::Simple::Proc::information usage procedure
      2.4.29 ::Simple::Proc::move sourceProcedure targetProcedure
      2.4.30 ::Simple::Proc::resolve-alias procedure
      2.4.31 ::Simple::Script::Header::add scriptName tag priority header
      2.4.32 ::Simple::Script::Header::delete scriptName ?pattern?
      2.4.33 ::Simple::Script::Header::get script ?pattern?
      2.4.34 ::Simple::Script::Trailer::add scriptName tag priority trailer
      2.4.35 ::Simple::Script::Trailer::delete scriptName ?pattern?
      2.4.36 ::Simple::Script::Trailer::get script ?pattern?
      2.4.37 ::Simple::Script::append scriptName scriptToAppend
   2.5 Errors
      2.5.1 ::Simple::Proc::NON-EXISTING-NAMESPACE
      2.5.2 ::Simple::Proc::TYPE-CHECKING-AND-NO-PARSE-FLAGS
      2.5.3 ::Simple::Proc::ARGS-MUST-BE-LAST
      2.5.4 ::Simple::Proc::NON-OPT-AFTER-OPT
      2.5.5 ::Simple::Proc::DEFAULT-NOT-ALLOWED
      2.5.6 ::Simple::Proc::ARGS-NOT-ALLOWED
      2.5.7 ::Simple::Proc::ARGS-LIST-OR-ANY
      2.5.8 ::Simple::Proc::NO-FLAG-PARSING-AND-NO-FLAGS
      2.5.9 ::Simple::Proc::NO-PARAM-FOR-FLAG
      2.5.10 ::Simple::Proc::CANT-BETWEEN-SUBCO-AND-NO-SUBCO
      2.5.11 ::Simple::Proc::NON-EXISTING-PROCEDURE
      2.5.12 ::Simple::Proc::NON-EXISTING-ARGUMENT
      2.5.13 ::Simple::Proc::NO-TYPE-CHOICE
      2.5.14 ::Simple::Proc::CANT-BE-CALLED-FROM-TOPLEVEL
      2.5.15 ::Simple::Script::DUPLICATED-TAG
      2.5.16 ::Simple::Proc::VALUE-REQUIRED
      2.5.17 ::Simple::Proc::ARRAY-NOT-ALLOWED
      2.5.18 ::Simple::Proc::OPTIONAL-FLAG
3. Package further information
   3.1 Details
   3.2 Remarks
   3.3 Todo
4. Package command details
   4.1 ::Simple::Argument::check-type args
      4.1.1 Command description
         4.1.1.1 Overview
         4.1.1.2 Examples
      4.1.2 Command public API
      4.1.3 Command further information
         4.1.3.1 Remarks
   4.2 ::Simple::Argument::information choices procedure argument
      4.2.1 Command description
      4.2.2 Command public API
   4.3 ::Simple::Argument::information default procedure argument
      4.3.1 Command description
      4.3.2 Command public API
   4.4 ::Simple::Argument::information defaultgiven procedure argument
      4.4.1 Command description
      4.4.2 Command public API
   4.5 ::Simple::Argument::information description procedure argument
      4.5.1 Command description
      4.5.2 Command public API
   4.6 ::Simple::Argument::information flaggiven flag
      4.6.1 Command description
         4.6.1.1 Examples
      4.6.2 Command public API
      4.6.3 Command further information
         4.6.3.1 References
   4.7 ::Simple::Argument::information givenflags
      4.7.1 Command description
         4.7.1.1 Overview
      4.7.2 Command public API
      4.7.3 Command further information
         4.7.3.1 References
   4.8 ::Simple::Argument::information isdefault argument
      4.8.1 Command description
         4.8.1.1 Overview
         4.8.1.2 Examples
      4.8.2 Command public API
      4.8.3 Command further information
         4.8.3.1 References
   4.9 ::Simple::Argument::information type procedure argument
      4.9.1 Command description
      4.9.2 Command public API
   4.10 ::Simple::Proc::cget ?-checktype? ?-afterflags?
      4.10.1 Command description
      4.10.2 Command public API
   4.11 ::Simple::Proc::configure ?-checktype extbool? ?-afterflags integer?
      4.11.1 Command description
      4.11.2 Command public API
   4.12 proc-ext ?-parseflags extbool? ?-checktype extbool? procedure arguments body
      4.12.1 Command description
         4.12.1.1 Overview
            4.12.1.1.1 Extended format arguments
               4.12.1.1.1.1 Argument name
               4.12.1.1.1.2 Argument type
               4.12.1.1.1.3 Argument default value or choice list
               4.12.1.1.1.4 Argument description
            4.12.1.1.2 Run-time handling
         4.12.1.2 Examples
      4.12.2 Command public API
      4.12.3 Command further information
         4.12.3.1 Details
         4.12.3.2 Remarks
   4.13 ::Simple::Proc::delete procedure
      4.13.1 Command description
         4.13.1.1 Overview
      4.13.2 Command public API
      4.13.3 Command further information
         4.13.3.1 Remarks
   4.14 ::Simple::Proc::information access procedure
      4.14.1 Command description
      4.14.2 Command public API
   4.15 ::Simple::Proc::information alias procedure
      4.15.1 Command description
      4.15.2 Command public API
   4.16 ::Simple::Proc::information args procedure
      4.16.1 Command description
         4.16.1.1 Overview
      4.16.2 Command public API
   4.17 ::Simple::Proc::information arguments procedure
      4.17.1 Command description
      4.17.2 Command public API
   4.18 ::Simple::Proc::information body procedure
      4.18.1 Command description
         4.18.1.1 Overview
      4.18.2 Command public API
   4.19 ::Simple::Proc::information caller ?levels?
      4.19.1 Command description
         4.19.1.1 Overview
      4.19.2 Command public API
   4.20 ::Simple::Proc::information checktype procedure
      4.20.1 Command description
      4.20.2 Command public API
      4.20.3 Command further information
         4.20.3.1 Remarks
   4.21 ::Simple::Proc::information exists procedure
      4.21.1 Command description
         4.21.1.1 Overview
      4.21.2 Command public API
   4.22 ::Simple::Proc::information isextended procedure
      4.22.1 Command description
      4.22.2 Command public API
   4.23 ::Simple::Proc::information issubcommand procedure
      4.23.1 Command description
      4.23.2 Command public API
      4.23.3 Command further information
         4.23.3.1 References
   4.24 ::Simple::Proc::information metadata procedure
      4.24.1 Command description
         4.24.1.1 Overview
      4.24.2 Command public API
   4.25 ::Simple::Proc::information parseflags procedure
      4.25.1 Command description
      4.25.2 Command public API
      4.25.3 Command further information
         4.25.3.1 Remarks
   4.26 ::Simple::Proc::information runtimeparsing procedure
      4.26.1 Command description
      4.26.2 Command public API
      4.26.3 Command further information
         4.26.3.1 Remarks
   4.27 ::Simple::Proc::information subcommands command
      4.27.1 Command description
      4.27.2 Command public API
      4.27.3 Command further information
         4.27.3.1 References
         4.27.3.2 Remarks
   4.28 ::Simple::Proc::information usage procedure
      4.28.1 Command description
         4.28.1.1 Examples
      4.28.2 Command public API
      4.28.3 Command further information
         4.28.3.1 References
         4.28.3.2 Remarks
   4.29 ::Simple::Proc::move sourceProcedure targetProcedure
      4.29.1 Command description
         4.29.1.1 Overview
      4.29.2 Command public API
      4.29.3 Command further information
         4.29.3.1 Remarks
         4.29.3.2 Todo
   4.30 ::Simple::Proc::resolve-alias procedure
      4.30.1 Command description
         4.30.1.1 Overview
      4.30.2 Command public API
   4.31 ::Simple::Script::Header::add scriptName tag priority header
      4.31.1 Command description
         4.31.1.1 Overview
      4.31.2 Command public API
   4.32 ::Simple::Script::Header::delete scriptName ?pattern?
      4.32.1 Command description
         4.32.1.1 Overview
      4.32.2 Command public API
      4.32.3 Command further information
         4.32.3.1 Remarks
   4.33 ::Simple::Script::Header::get script ?pattern?
      4.33.1 Command description
         4.33.1.1 Overview
      4.33.2 Command public API
      4.33.3 Command further information
         4.33.3.1 Remarks
   4.34 ::Simple::Script::Trailer::add scriptName tag priority trailer
      4.34.1 Command description
         4.34.1.1 Overview
      4.34.2 Command public API
   4.35 ::Simple::Script::Trailer::delete scriptName ?pattern?
      4.35.1 Command description
         4.35.1.1 Overview
      4.35.2 Command public API
      4.35.3 Command further information
         4.35.3.1 Remarks
   4.36 ::Simple::Script::Trailer::get script ?pattern?
      4.36.1 Command description
         4.36.1.1 Overview
      4.36.2 Command public API
      4.36.3 Command further information
         4.36.3.1 Remarks
   4.37 ::Simple::Script::append scriptName scriptToAppend
      4.37.1 Command description
      4.37.2 Command public API

1. Package description

Synopsis: the Simple Development Library procedures with extended argument syntax.

Keywords: procedure, extended, argument, type and flag.

1.1 Overview

This package provides a way to create procedures with extended argument syntax. This syntax includes argument types (with optional run-time type checking) and flag arguments with or without parameters which may be automatically parsed or left for the user to parse.

Procedures are provided to create, delete, rename and get information about procedures with extended argument syntax, as well as others to handle arguments in the body of those procedures, such as assess whether certain flag has been given in the command line or assess whether the value of a flag is that flag value.

This package also allows to handle headers and trailers for code scripts. Each header or trailer is identified by a tag and, within a script, headers and trailers are ordered by increasing priority. Procedures are provided to add, get and delete script headers and trailers.

1.2 Usage

Extended syntax procedures are created via the ::Simple::Proc::create procedure. The declaration specifies whether to perform run-time checking of the arguments types as well as whether to delegate the flag parsing to the user.

Extended argument syntax procedures can be deleted via ::Simple::Proc::delete or renamed via ::Simple::Proc::move. The ::Simple::Proc::information procedure provides several subcommands to query information about extended argument syntax procedures: issubcommand, subcommands, runtimeparsing, checktype, parseflags, exists, body, args, usage, arguments, type, default, choices, metadata and description.

The syntax of the extended arguments is similar to that of the arguments used by the opt package distributed with Tcl, so the upgrade for users using that should be easy; in fact this package was implemented as an evolution of the opt package for two reasons: 1) opt is slow and 2) it was deprecated from Tcl 8.1 (made private, actually).

This argument syntax is of the form {name type ?value? description}. There, "name" is the argument name, "type" its type, "value" its default value or choice list and "description" a string describing the argument. Types used by opt are of the form "-float", while The Simple Development Library removes the hyphen to yield "float"; further, some opt types are abbreviated (such as "int") while The Simple Development Library uses mostly unabbreviated names such as "integer". See the SimpleType package for further information about types. Extended arguments are further described in the proc-ext procedure.

The presence or absence of a regular flag in an extended procedure call argument list can be obtained via the ::Simple::Argument::information flaggiven procedure, while the complete list of all given flags is returned by ::Simple::Argument::information givenflags. For flags or optional arguments, ::Simple::Argument::information isdefault returns whether an extended procedure argument actual value matches its corresponding default value. Other subcommands of the ::Simple::Argument::information command are <description>, defaultgiven, default, type and choices.

This package encompasses the funcionality provided by the SimpleSubcommand package, so it is recommended not to directly use the later if using the former. In fact, all procedures provided by this package work for regular procedures also, so this is the only package needed to handle regular or extended argument syntax procedures as well as regular or subcommand procedures. Nevertheless, see the SimpleDeclare package declare-proc command, which encompasses proc-ext in turn.

The ::Simple::Proc::convert pair of procedures convert between extended and Tcl canonical procedure argument formats.

::Simple::Script::append allows to append scripts. The ::Simple::Script::Header::add and ::Simple::Script::Trailer::add procedures prepend a header or append a trailer to a script, respectively. Headers and trailers can be got or deleted with the ::Simple::Script::Header::get, ::Simple::Script::Trailer::get, ::Simple::Script::Header::delete and ::Simple::Script::Trailer::delete procedures.

1.3 Examples

1.4 History

Date Reason
19-feb-1999 Unreleased first version 0.1
23-apr-2000 First public release, version 0.2
10-sep-2001 Second public release, version 0.4
17-feb-2003 Third public release, version 0.5
30-mar-2003 Extra package, version 0.5.1
24-oct-2004 Copy functionality deleted, version 0.5.2
03-dec-2004 SimpleRegProc functionality moved here and changes to ::Simple::Proc::information subcommands, version 0.5.3
11-may-2005 Bug 11 correction, version 0.5.4
22-jun-2005 The Simple Development Library version 1.0

1.5 Copyright

Copyright (C) 1999-2005, Juan C. Gil (jgil@gmv.es).

2. Package public API

Paradigm: procedural.

Requisites: SimpleVariable 1.0.

2.1 Types

2.1.1 extendedarg

Description: extended format argument as {name type ?value? description}.

2.1.2 canonicalarg

Description: canonical argument as {name ?value?}.

2.2 Options

2.2.1 -checktype

Type: boolean.

Value: 0.

Description: whether argument run-time type checking is performed for procedures created via the ::Simple::Proc::create procedure in order to check whether the actual arguments match their type. This has a performance penalty which should be considered. Notice that only those procedures created via the ::Simple::Proc::create procedure after modifying this option are affected by the change.

2.2.2 -afterflags

Type: integer.

Value: 5.

Description: if the number of arguments after the last flag in procedures created via the ::Simple::Proc::create procedure exceedes the value of this package option, those arguments are handled via an auxiliary "after flags" procedure. The optimum value of this parameter depends on the Tcl version used. The Simple Development Library default value corresponds to the latest Tcl version. Notice that only those procedures created via the ::Simple::Proc::create procedure after modifying this option are affected by the change.

2.3 Namespaces

  1. ::Simple::Proc

  2. ::Simple::Proc::Priv

  3. ::Simple::Argument

  4. ::Simple::Script

  5. ::Simple::Script::Header

  6. ::Simple::Script::Trailer

  7. ::Simple::Script::Priv

2.4 Commands

2.4.1 ::Simple::Argument::check-type args

Synopsis: perform runtime type checking on named arguments.

Details: see section 4.1.

2.4.2 ::Simple::Argument::information choices procedure argument

Synopsis: returns an extended procedure argument choices list.

Details: see section 4.2.

2.4.3 ::Simple::Argument::information default procedure argument

Synopsis: returns a procedure argument default value.

Details: see section 4.3.

2.4.4 ::Simple::Argument::information defaultgiven procedure argument

Synopsis: returns whether a procedure argument has a default value.

Details: see section 4.4.

2.4.5 ::Simple::Argument::information description procedure argument

Synopsis: returns an extended procedure argument description.

Details: see section 4.5.

2.4.6 ::Simple::Argument::information flaggiven flag

Synopsis: returns whether a flag was given in an extended procedure call.

Details: see section 4.6.

2.4.7 ::Simple::Argument::information givenflags

Synopsis: returns the flags and their parameters in an extended procedure call.

Details: see section 4.7.

2.4.8 ::Simple::Argument::information isdefault argument

Synopsis: returns whether an argument value is the default one.

Details: see section 4.8.

2.4.9 ::Simple::Argument::information type procedure argument

Synopsis: returns an extended procedure argument type.

Details: see section 4.9.

2.4.10 ::Simple::Proc::cget ?-checktype? ?-afterflags?

Synopsis: gets the package options.

Details: see section 4.10.

2.4.11 ::Simple::Proc::configure ?-checktype extbool? ?-afterflags integer?

Synopsis: configures the package options.

Details: see section 4.11.

2.4.12 proc-ext ?-parseflags extbool? ?-checktype extbool? procedure arguments body

Synopsis: creates a procedure with extended argument syntax.

Details: see section 4.12.

2.4.13 ::Simple::Proc::delete procedure

Synopsis: deletes a procedure.

Details: see section 4.13.

2.4.14 ::Simple::Proc::information access procedure

Synopsis: returns a declared procedure access mode.

Details: see section 4.14.

2.4.15 ::Simple::Proc::information alias procedure

Synopsis: returns a declared procedure alias.

Details: see section 4.15.

2.4.16 ::Simple::Proc::information args procedure

Synopsis: returns a procedure argument names list.

Details: see section 4.16.

2.4.17 ::Simple::Proc::information arguments procedure

Synopsis: returns a procedure argument list.

Details: see section 4.17.

2.4.18 ::Simple::Proc::information body procedure

Synopsis: returns a procedure body.

Details: see section 4.18.

2.4.19 ::Simple::Proc::information caller ?levels?

Synopsis: returns the caller procedure name.

Details: see section 4.19.

2.4.20 ::Simple::Proc::information checktype procedure

Synopsis: returns whether a procedure performs argument type checking.

Details: see section 4.20.

2.4.21 ::Simple::Proc::information exists procedure

Synopsis: returns whether a procedure exists.

Details: see section 4.21.

2.4.22 ::Simple::Proc::information isextended procedure

Synopsis: returns whether a procedure is an extended procedure.

Details: see section 4.22.

2.4.23 ::Simple::Proc::information issubcommand procedure

Synopsis: returns whether a procedure is a base command procedure.

Details: see section 4.23.

2.4.24 ::Simple::Proc::information metadata procedure

Synopsis: returns a declared procedure metadata.

Details: see section 4.24.

2.4.25 ::Simple::Proc::information parseflags procedure

Synopsis: returns whether a procedure has flag parsing enabled.

Details: see section 4.25.

2.4.26 ::Simple::Proc::information runtimeparsing procedure

Synopsis: returns whether a procedure run-time parses its arguments.

Details: see section 4.26.

2.4.27 ::Simple::Proc::information subcommands command

Synopsis: returns a base command procedure subcommand list.

Details: see section 4.27.

2.4.28 ::Simple::Proc::information usage procedure

Synopsis: returns a procedure argument usage string.

Details: see section 4.28.

2.4.29 ::Simple::Proc::move sourceProcedure targetProcedure

Synopsis: renames a procedure.

Details: see section 4.29.

2.4.30 ::Simple::Proc::resolve-alias procedure

Synopsis: resolves command aliases.

Details: see section 4.30.

2.4.31 ::Simple::Script::Header::add scriptName tag priority header

Synopsis: prepends a header to a script.

Details: see section 4.31.

2.4.32 ::Simple::Script::Header::delete scriptName ?pattern?

Synopsis: deletes headers from a script.

Details: see section 4.32.

2.4.33 ::Simple::Script::Header::get script ?pattern?

Synopsis: gets headers from a script.

Details: see section 4.33.

2.4.34 ::Simple::Script::Trailer::add scriptName tag priority trailer

Synopsis: appends a trailer to a script.

Details: see section 4.34.

2.4.35 ::Simple::Script::Trailer::delete scriptName ?pattern?

Synopsis: deletes trailers from a script.

Details: see section 4.35.

2.4.36 ::Simple::Script::Trailer::get script ?pattern?

Synopsis: gets trailers from a script.

Details: see section 4.36.

2.4.37 ::Simple::Script::append scriptName scriptToAppend

Synopsis: appends a non-empty script to another one.

Details: see section 4.37.

2.5 Errors

2.5.1 ::Simple::Proc::NON-EXISTING-NAMESPACE

Message: can't create procedure "procedure": unknown namespace.

Explanation: the extended procedure procedure could not be created because the namespace does not exist.

Corrective action: use namespace eval to create the namespace.

2.5.2 ::Simple::Proc::TYPE-CHECKING-AND-NO-PARSE-FLAGS

Message: can not have "-parseflags false" and argument run-time type checking.

Explanation: a procedure declaration failed because argument run-time type checking was enabled and flag parsing disabled.

Corrective action: either disable argument run-time type checking or enable flag parsing.

2.5.3 ::Simple::Proc::ARGS-MUST-BE-LAST

Message: "args" must be the last argument.

Explanation: a procedure declaration failed because an argument named "args" was supplied not the last in the list.

2.5.4 ::Simple::Proc::NON-OPT-AFTER-OPT

Message: non-optional argument "argument" after at least one optional argument.

Explanation: a procedure declaration failed because the non-optional argument argument was supplied after an optional argument.

Corrective action: all arguments following an optional one must be either explicitly optional or the special argument "args" which is implictly optional.

2.5.5 ::Simple::Proc::DEFAULT-NOT-ALLOWED

Message: can not have a default value for option or argument "option or argument name" of type "type".

Explanation: a procedure or option declaration failed because a default value was supplied for an option or argument which can not have it.

Corrective action: default values must be supplied for procedure optional arguments and for flags or options whose type is not "boolflag", and only for those.

2.5.6 ::Simple::Proc::ARGS-NOT-ALLOWED

Message: "args" is not allowed if flag parsing is disabled.

Explanation: a procedure declaration failed because an argument named "args" was supplied but flag parsing is disabled.

Corrective action: either remove the "args" argument or enable flags parsing.

2.5.7 ::Simple::Proc::ARGS-LIST-OR-ANY

Message: "args" must be of type "list" or "any".

Explanation: a procedure declaration failed because an argument named "args" was supplied with a type other than "list" or "any".

2.5.8 ::Simple::Proc::NO-FLAG-PARSING-AND-NO-FLAGS

Message: flag parsing disabled but no flags given.

Explanation: a procedure declaration failed because flag parsing was diabled but no flags were given in the argument list.

Corrective action: enable flag parsing.

2.5.9 ::Simple::Proc::NO-PARAM-FOR-FLAG

Message: no parameter given for flag "flag" to "procedure".

Explanation: a call to the procedure procedure failed because no parameter was supplied for the flag flag.

Corrective action: supply a parameter for the flag.

2.5.10 ::Simple::Proc::CANT-BETWEEN-SUBCO-AND-NO-SUBCO

Message: can't copy or rename [non-]subcommand "name 1" to [non-]subcommand "name 2".

Explanation: it is not allowed to copy or rename a non-subcommand to a subcommand or viceversa.

2.5.11 ::Simple::Proc::NON-EXISTING-PROCEDURE

Message: "procedure" isn't a procedure, an extended procedure or a declared procedure.

Explanation: procedure is not a procedure, an extended procedure or a declared procedure.

Corrective action: provide a valid procedure name.

2.5.12 ::Simple::Proc::NON-EXISTING-ARGUMENT

Message: procedure "procedure" doesn't have an argument "argument".

Explanation: procedure procedure does not have an argument named argument.

Corrective action: provide an argument from the procedure argument list.

2.5.13 ::Simple::Proc::NO-TYPE-CHOICE

Message: argument "argument" from procedure "procedure" is not of type "choice" nor "choice-list".

Explanation: the extended procedure procedure argument argument type is not "choice" nor "choice-list".

2.5.14 ::Simple::Proc::CANT-BE-CALLED-FROM-TOPLEVEL

Message: "procedure" can't be called from the top level.

Explanation: it makes no sense to call procedure procedure from the top level.

Corrective action: call the procedure from a level other than the top one.

2.5.15 ::Simple::Script::DUPLICATED-TAG

Message: duplicated header or trailer with tag "tag" in script "script".

Explanation: script script already contains a header or trailer with tag tag.

Corrective action: use ::Simple::Script::Header::delete or ::Simple::Script::Trailer::delete to delete the header with that tag or use another tag.

2.5.16 ::Simple::Proc::VALUE-REQUIRED

Message: a value is required for optional or flag argument "optional or flag argument name".

Explanation: optional or flag argument optional or flag argument name requires a value, but no value was supplied.

Corrective action: supply a value for the optional or flag argument.

2.5.17 ::Simple::Proc::ARRAY-NOT-ALLOWED

Message: derived array type "type" not allowed for argument or option "argument or option name".

Explanation: a derived array type type has been used for argument or option argument or option name but that is not allowed.

Corrective action: for arguments, a derived array type can be emulated using upvar.

2.5.18 ::Simple::Proc::OPTIONAL-FLAG

Message: cannot have an explicit optional flag "flag".

Explanation: flag flag was explicitly stated as optional while all flags are implicitly optional.

Corrective action: remove the question marks around the flag name.

3. Package further information

3.1 Details

0 whether the argument is a flag
1 whether the argument has a default value
2 argument name
3 argument default value
4 argument type
5 argument choices (empty if type is not "choice" nor derived from it)
6 argument description

3.2 Remarks

3.3 Todo

4. Package command details

4.1 ::Simple::Argument::check-type args

4.1.1 Command description

Synopsis: perform runtime type checking on named arguments.

Access mode: public.

Keywords: argument and type.

4.1.1.1 Overview

Performs runtime type checking of specific arguments for the calling procedure when runtime type checking is turned off. If runtime type checking is turned on for the calling procedure, this procedure does nothing.

This procedure is useful to force run-time type checking for a subset of arguments even when run-time type checking is explicitly turned off.

4.1.1.2 Examples

4.1.2 Command public API

Arguments:

Argument Type Default value/ choices Description
args list (n/a) List of argument names

Returns: whether runtime type checking was performed.

4.1.3 Command further information

4.1.3.1 Remarks

4.2 ::Simple::Argument::information choices procedure argument

4.2.1 Command description

Synopsis: returns an extended procedure argument choices list.

Access mode: public.

4.2.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name
argument unqualifiedname (n/a) Argument name

Returns: the extended procedure argument choices list.

4.3 ::Simple::Argument::information default procedure argument

4.3.1 Command description

Synopsis: returns a procedure argument default value.

Access mode: public.

4.3.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name
argument unqualifiedname (n/a) Argument name

Returns: whether the procedure argument has a default value.

4.4 ::Simple::Argument::information defaultgiven procedure argument

4.4.1 Command description

Synopsis: returns whether a procedure argument has a default value.

Access mode: public.

4.4.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name
argument unqualifiedname (n/a) Argument name

Returns: whether the procedure argument has a default value.

4.5 ::Simple::Argument::information description procedure argument

4.5.1 Command description

Synopsis: returns an extended procedure argument description.

Access mode: public.

4.5.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name
argument unqualifiedname (n/a) Argument name

Returns: the extended procedure argument desription.

4.6 ::Simple::Argument::information flaggiven flag

4.6.1 Command description

Synopsis: returns whether a flag was given in an extended procedure call.

Access mode: public.

Keywords: procedure, argument and flag.

4.6.1.1 Examples

4.6.2 Command public API

Arguments:

Argument Type Default value/ choices Description
flag flag (n/a) Flag name

Returns: whether the flag was given in the actual argument list.

Limitations:

4.6.3 Command further information

4.6.3.1 References

4.7 ::Simple::Argument::information givenflags

4.7.1 Command description

Synopsis: returns the flags and their parameters in an extended procedure call.

Access mode: public.

Keywords: procedure, argument and flag.

4.7.1.1 Overview

This procedure returns the list of flags and their parameters given in an extended procedure call. The format of the returned list is suitable to be given as argument to the array get command: the array indices would be the flags and the array values their parameters.

Notice that for boolean flags (type "boolflag") the value is always 1.

4.7.2 Command public API

Arguments: none.

Returns: the list of flags and their parameters given in the actual argument list.

Limitations:

4.7.3 Command further information

4.7.3.1 References

4.8 ::Simple::Argument::information isdefault argument

4.8.1 Command description

Synopsis: returns whether an argument value is the default one.

Access mode: public.

Keywords: procedure, argument and default value.

4.8.1.1 Overview

For flags or optional arguments, this procedure returns whether its actual value matches its corresponding default value. For other arguments the procedure returns always false.

4.8.1.2 Examples

4.8.2 Command public API

Arguments:

Argument Type Default value/ choices Description
argument unqualifiedname (n/a) Argument name

Returns: whether the argument has a default value and it matches its actual value.

Limitations:

4.8.3 Command further information

4.8.3.1 References

4.9 ::Simple::Argument::information type procedure argument

4.9.1 Command description

Synopsis: returns an extended procedure argument type.

Access mode: public.

4.9.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name
argument unqualifiedname (n/a) Argument name

Returns: the extended procedure argument type.

4.10 ::Simple::Proc::cget ?-checktype? ?-afterflags?

4.10.1 Command description

Synopsis: gets the package options.

Access mode: public.

4.10.2 Command public API

Arguments:

Argument Type Default value/ choices Description
-checktype boolflag (n/a) Gets whether to perform run-time type checking of the procedures arguments
-afterflags boolflag (n/a) Gets the minimum number of arguments after the last flag for a procedure in order for those to be handled with an auxiliary "after flags" procedure

Returns: the requested option value or the whole list of options if none specified.

4.11 ::Simple::Proc::configure ?-checktype extbool? ?-afterflags integer?

4.11.1 Command description

Synopsis: configures the package options.

Access mode: public.

4.11.2 Command public API

Arguments:

Argument Type Default value/ choices Description
?-checktype? extbool false Whether to perform run-time type checking of the procedures arguments
?-afterflags? integer 5 Minimum number of arguments after the last flag for a procedure in order for those to be handled with an auxiliary "after flags" procedure

Returns: the empty string.

4.12 proc-ext ?-parseflags extbool? ?-checktype extbool? procedure arguments body

(Alias for ::Simple::Proc::create).

4.12.1 Command description

Synopsis: creates a procedure with extended argument syntax.

Access mode: public.

Keywords: procedure, argument, type and flag.

4.12.1.1 Overview

This procedure acts as an interface to the proc command to create other procedures allowing a richer syntax for their arguments. Upon creation of a new procedure, its extended format argument list is parsed and converted into a canonical argument list (in which each argument has the format {name ?defaultValue?}) which is used to actually create the procedure via the proc command. If the argument list contains one or more flags, or if run-time type checking is requested, the procedure body is instrumented to add run-time handling of the argument list.

If the procedure name is two words, a subcommand procedure similar to that created via the SimpleSubcommand package proc-sub procedure is created, but with extended argument syntax. It is thus not required to use proc-sub when using this package.

4.12.1.1.1 Extended format arguments

Extended syntax arguments are of the form {name type ?value? description}

4.12.1.1.1.1 Argument name

Arguments whose name starts by a hyphen are flags. The presence of flags in the procedure call actual argument list is optional but.

Flags whose type is boolflag are boolean flags and do not require a parameter. For each boolean flag in the argument list, a variable is created in the procedure body with the same name as the flag (excluding the hyphen) and whose value is true or false (1 or 0) depending on whether the flag is given or not in the procedure call actual argument list.

Flags whose type is not boolflag are regular flags and require a parameter; the flag type is the expected parameter type. For each regular flag in the argument list, a variable is created in the procedure body with the same name as the flag (excluding the hyphen) and whose value is the parameter supplied after the flag, or its default value if the flag was not given in the procedure call actual argument list. The presence or absence of a regular flag in the procedure call actual argument list can be checked via the ::Simple::Argument::information flaggiven procedure.

The list of all flags in the procedure call actual argument list together with their parameters can be obtained via the ::Simple::Argument::information givenflags.

Arguments whose name is enclosed between question marks are optional. They differ from the flags in that they behave exactly as optional arguments to the proc command, that is, they must appear at the end of the argument list.

As with the proc command, the args special argument collects all remaining arguments in the actual argument list and combines them into a list which is available to the procedure body in the variable name args. If given, the args special argument must be the last one.

4.12.1.1.1.2 Argument type

The argument type must be a type known by The Simple Development Library, that is, any Simple Development Library type or declared via the ::Simple::Type::declare procedure.

An actual argument whose type is choice can only hold one of the values specified in the argument declaration default value field.

See also the boolflag type in the argument name section above.

4.12.1.1.1.3 Argument default value or choice list

An argument declaration can specify this field if and only if its type is choice, an optional argument, or a flag whose type is not boolflag. For arguments of type choice, this field specifies the list of allowed choices; otherwise, it corresponds to the parameter default value. For optional arguments of type choice, the default value is the first choice.

4.12.1.1.1.4 Argument description

This is simply a description of the argument.

4.12.1.1.2 Run-time handling

The -checktype flag allows to override the package option of the same name for the procedure being created. This option controls whether a run-time type check is performed to assess whether the arguments contents match their type. This has a performance penalty which should be considered. The overhead comes from two fronts. First, the contents of each argument must be checked. Second, it is not possible to apply the improving performance tricks described in the details section below.

The -parseflags flag allows to disable the flag parsing which is delegated to the user. This results in better performance (the procedure call is equivalent to a regular Tcl proc procedure) at the cost of some hassle and restrictions:

4.12.1.2 Examples

4.12.2 Command public API

Arguments:

Argument Type Default value/ choices Description
?-parseflags? extbool true Whether to enable flag parsing or delegate it to the user
?-checktype? extbool false Whether to enable argument run-time type checking
procedure commandname (n/a) Procedure name
arguments extendedarg-list (n/a) Extended argument list
body script (n/a) Procedure body

Returns: the empty string.

Effects:

4.12.3 Command further information

4.12.3.1 Details

4.12.3.2 Remarks

4.13 ::Simple::Proc::delete procedure

4.13.1 Command description

Synopsis: deletes a procedure.

Access mode: public.

4.13.1.1 Overview

This command is similar to the rename command when its second argument is the empty string, but works for extended procedures as well as for regular procedures.

4.13.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the empty string.

Effects:

4.13.3 Command further information

4.13.3.1 Remarks

4.14 ::Simple::Proc::information access procedure

4.14.1 Command description

Synopsis: returns a declared procedure access mode.

Access mode: public.

4.14.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the declared procedure access mode.

4.15 ::Simple::Proc::information alias procedure

4.15.1 Command description

Synopsis: returns a declared procedure alias.

Access mode: public.

4.15.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the declared procedure alias.

4.16 ::Simple::Proc::information args procedure

4.16.1 Command description

Synopsis: returns a procedure argument names list.

Access mode: public.

4.16.1.1 Overview

This command is similar to the info args command, but works for extended procedures as well as for regular procedures.

4.16.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the procedure argument names list.

4.17 ::Simple::Proc::information arguments procedure

4.17.1 Command description

Synopsis: returns a procedure argument list.

Access mode: public.

4.17.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the procedure argument list.

4.18 ::Simple::Proc::information body procedure

4.18.1 Command description

Synopsis: returns a procedure body.

Access mode: public.

4.18.1.1 Overview

This command is similar to the info body, but works for extended procedures as well as for regular procedures.

4.18.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the procedure body.

4.19 ::Simple::Proc::information caller ?levels?

4.19.1 Command description

Synopsis: returns the caller procedure name.

Access mode: public.

4.19.1.1 Overview

This procedure returns the name of a procedure up the calling stack. By default, one level up the stack is used.

4.19.2 Command public API

Arguments:

Argument Type Default value/ choices Description
?levels? integer 1 Levels up the stack in which to operate

Returns: the caller procedure name or the empty string if not found.

4.20 ::Simple::Proc::information checktype procedure

4.20.1 Command description

Synopsis: returns whether a procedure performs argument type checking.

Access mode: public.

4.20.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: whether the procedure performs argument type checking.

4.20.3 Command further information

4.20.3.1 Remarks

4.21 ::Simple::Proc::information exists procedure

4.21.1 Command description

Synopsis: returns whether a procedure exists.

Access mode: public.

4.21.1.1 Overview

This command returns whether a procedure exists, being it extended or not.

4.21.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: whether the procedure exists.

4.22 ::Simple::Proc::information isextended procedure

4.22.1 Command description

Synopsis: returns whether a procedure is an extended procedure.

Access mode: public.

4.22.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: whether the extended procedure exists.

4.23 ::Simple::Proc::information issubcommand procedure

4.23.1 Command description

Synopsis: returns whether a procedure is a base command procedure.

Access mode: public.

4.23.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: whether the procedure is a base command procedure.

4.23.3 Command further information

4.23.3.1 References

4.24 ::Simple::Proc::information metadata procedure

4.24.1 Command description

Synopsis: returns a declared procedure metadata.

Access mode: public.

4.24.1.1 Overview

This procedure returns a list of pairs suitable to be given as argument to the array set command. Each element is one of the flags given to declare-proc upon procedure declaration (with no hypen), but for -arguments, -access, -alias and -body (these are obtained using specific ::Simple::Proc::information subcommands), and the items stored by proc-ext (parseflags and checktype; these are also obtained using specific ::Simple::Proc::information subcommands).

Thus, the actual list of flags is: -version, -project, -synopsis, -overview, -returns, -keywords, -examples, -assumptions, -resources, -limitations, -effects, -details, -references, -remarks, -todo, -history and -copyright.

Notice that no data is returned unless The Simple Development Library -storemetadata option is set when the procedure was declared.

If a particular flag was not given in the procedure declaration, the empty string is returned as that flag contents.

4.24.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the declared procedure metadata as an item/contents pairs list.

4.25 ::Simple::Proc::information parseflags procedure

4.25.1 Command description

Synopsis: returns whether a procedure has flag parsing enabled.

Access mode: public.

4.25.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: whether the procedure has flag parsing enabled.

4.25.3 Command further information

4.25.3.1 Remarks

4.26 ::Simple::Proc::information runtimeparsing procedure

4.26.1 Command description

Synopsis: returns whether a procedure run-time parses its arguments.

Access mode: public.

4.26.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: whether the procedure run-time parses its arguments.

4.26.3 Command further information

4.26.3.1 Remarks

4.27 ::Simple::Proc::information subcommands command

4.27.1 Command description

Synopsis: returns a base command procedure subcommand list.

Access mode: public.

4.27.2 Command public API

Arguments:

Argument Type Default value/ choices Description
command name (n/a) Base command name

Returns: the base command procedure subcommand list.

4.27.3 Command further information

4.27.3.1 References

4.27.3.2 Remarks

4.28 ::Simple::Proc::information usage procedure

4.28.1 Command description

Synopsis: returns a procedure argument usage string.

Access mode: public.

4.28.1.1 Examples

4.28.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure commandname (n/a) Procedure name

Returns: the procedure argument usage string.

4.28.3 Command further information

4.28.3.1 References

4.28.3.2 Remarks

4.29 ::Simple::Proc::move sourceProcedure targetProcedure

4.29.1 Command description

Synopsis: renames a procedure.

Access mode: public.

4.29.1.1 Overview

This command is similar to the rename command when its second argument is non-empty, but works for extended procedures as well as for regular procedures.

4.29.2 Command public API

Arguments:

Argument Type Default value/ choices Description
sourceProcedure name (n/a) Source procedure name
targetProcedure name (n/a) Target procedure name

Returns: the empty string.

Effects:

4.29.3 Command further information

4.29.3.1 Remarks

4.29.3.2 Todo

4.30 ::Simple::Proc::resolve-alias procedure

4.30.1 Command description

Synopsis: resolves command aliases.

Access mode: public.

4.30.1.1 Overview

This procedure resolves one aliasing level for a command, if existing.

4.30.2 Command public API

Arguments:

Argument Type Default value/ choices Description
procedure name (n/a) Procedure name

Returns: the alias resolved command name.

Limitations:

4.31 ::Simple::Script::Header::add scriptName tag priority header

4.31.1 Command description

Synopsis: prepends a header to a script.

Access mode: public.

4.31.1.1 Overview

This command prepends a header to a script.

The header is enclosed between a begin and an end of header markers formatted through the MarkerFormat package variable. Both markers contain the header tag and priority. Successive headers within a script are ordered by increasing priority which goes from 0 to 9999. If a header with the same priority as the one being prepended already exists, the original has precedence, that is, the later gets added after the former.

4.31.2 Command public API

Arguments:

Argument Type Default value/ choices Description
scriptName name (n/a) Script name
tag string (n/a) Header tag
priority integer (n/a) Header priority
header script (n/a) Header

Returns: the empty string.

Effects:

4.32 ::Simple::Script::Header::delete scriptName ?pattern?

4.32.1 Command description

Synopsis: deletes headers from a script.

Access mode: public.

4.32.1.1 Overview

This procedure deletes script headers added by ::Simple::Script::Header::add matching the given pattern.

4.32.2 Command public API

Arguments:

Argument Type Default value/ choices Description
scriptName name (n/a) Script name
?pattern? pattern (empty string) Pattern

Returns: the number of deleted headers.

Effects:

4.32.3 Command further information

4.32.3.1 Remarks

4.33 ::Simple::Script::Header::get script ?pattern?

4.33.1 Command description

Synopsis: gets headers from a script.

Access mode: public.

4.33.1.1 Overview

This procedure returns the list of headers from a script added by ::Simple::Script::Header::add matching the given pattern.

4.33.2 Command public API

Arguments:

Argument Type Default value/ choices Description
script script (n/a) Script
?pattern? pattern (empty string) Pattern

Returns: the list of script headers matching the given pattern in the format {tag priority header}.

4.33.3 Command further information

4.33.3.1 Remarks

4.34 ::Simple::Script::Trailer::add scriptName tag priority trailer

4.34.1 Command description

Synopsis: appends a trailer to a script.

Access mode: public.

4.34.1.1 Overview

This command appends a trailer to a script.

The trailer is enclosed between a begin and an end of trailer markers formatted through the MarkerFormat package variable. Both markers contain the trailer tag and priority. Successive trailers within a script are ordered by increasing priority which goes from 0 to 9999. If a trailer with the same priority as the one being appended already exists, the original has precedence, that is, the later gets added after the former.

4.34.2 Command public API

Arguments:

Argument Type Default value/ choices Description
scriptName name (n/a) Script name
tag string (n/a) Trailer tag
priority integer (n/a) Trailer priority
trailer script (n/a) Trailer

Returns: the empty string.

Effects:

4.35 ::Simple::Script::Trailer::delete scriptName ?pattern?

4.35.1 Command description

Synopsis: deletes trailers from a script.

Access mode: public.

4.35.1.1 Overview

This procedure deletes script trailers added by ::Simple::Script::Trailer::add matching the given pattern.

4.35.2 Command public API

Arguments:

Argument Type Default value/ choices Description
scriptName name (n/a) Script name
?pattern? pattern (empty string) Pattern

Returns: the number of deleted trailers.

Effects:

4.35.3 Command further information

4.35.3.1 Remarks

4.36 ::Simple::Script::Trailer::get script ?pattern?

4.36.1 Command description

Synopsis: gets trailers from a script.

Access mode: public.

4.36.1.1 Overview

This procedure returns the list of trailers from a script added by ::Simple::Script::Trailer::add matching the given pattern.

4.36.2 Command public API

Arguments:

Argument Type Default value/ choices Description
script script (n/a) Script
?pattern? pattern (empty string) Pattern

Returns: the list of script trailers matching the given pattern in the format {tag priority header}.

4.36.3 Command further information

4.36.3.1 Remarks

4.37 ::Simple::Script::append scriptName scriptToAppend

4.37.1 Command description

Synopsis: appends a non-empty script to another one.

Access mode: public.

4.37.2 Command public API

Arguments:

Argument Type Default value/ choices Description
scriptName name (n/a) Script name
scriptToAppend script (n/a) Script to append

Returns: the empty string.

Effects: