Index: doc/Object.man =================================================================== diff -u -r430801481ec743e9b44376bc82f1568ac165cdf7 -rdb01a10696125a444bc827592087f56491900c2d --- doc/Object.man (.../Object.man) (revision 430801481ec743e9b44376bc82f1568ac165cdf7) +++ doc/Object.man (.../Object.man) (revision db01a10696125a444bc827592087f56491900c2d) @@ -495,6 +495,14 @@ [list_end] +[cmd_def method] + +[list_begin definitions] + +[include method.man.inc] + +[list_end] + [cmd_def move] [list_begin definitions] Index: doc/method.man.inc =================================================================== diff -u --- doc/method.man.inc (revision 0) +++ doc/method.man.inc (revision db01a10696125a444bc827592087f56491900c2d) @@ -0,0 +1,48 @@ +[comment {-*- tcl -*- manpage fragment for method method, shared by nx::Object and nx::Class}] + +[call [arg [vset CMD]] [opt "public | protected | private"] [const [vset SCOPE]] [method method] [arg name] [arg parameters] [opt [option "-checkalways"]] [opt [option "-returns [arg valueChecker]"]] [arg body]] + +[keywords "value checker"] +[keywords "colon-prefix notation"] +[keywords "self call"] +[keywords "alias method"] + +Defines a scripted method [arg methodName] for the scope of the [vset SCOPE]. The +method becomes part of the [vset SCOPE]'s signature interface. Besides +a [arg methodName], the method definition specifies +the method [arg parameters] and a method [arg body]. + +[para] + +[arg parameters] accepts a Tcl [cmd list] containing an arbitrary +number non-positional and positional parameter definitions. Each parameter +definition comprises a parameter name, a parameter-specific [term "value checker"], and +parameter options. + +[para] + +The [arg body] contains the method implementation as a script block. In this body script, the +colon-prefix notation is available to denote an object variable and +a [term "self call"]. In addition, the context of the object receiving the +method call (i.e., the message) can be accessed (e.g., using [cmd nx::self]) and +the call stack can be introspected (e.g., using [cmd nx::current]). + +[para] + +Optionally, [option "-returns"] allows for setting a [term "value checker"] on +values returned by the method implementation. By setting +the [term "switch"] [option "-checkalways"], value checking on +arguments and return value is guaranteed to be performed, even if +value checking is temporarily disabled; see [cmd nx::configure]). + +[para] + +A method closely resembles a Tcl [cmd proc], but it differs in some +important aspects: First, a method can define non-positional +parameters and value checkers on arguments. Second, the script +implementing the method body can contain object-specific notation and +commands (see above). Third, method calls [emph cannot] be intercepted +using Tcl [cmd trace]. Note that an existing Tcl [cmd proc] can be registered as +an [term "alias method"] (see [method "[vset SCOPE] alias"]). + +[comment {TODO: refer to nsf::proc?}]