diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-28 10:49:09 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-28 10:49:09 (GMT) |
commit | 63d86fb9f3f115b84b724d53884f8df7b7fa82fb (patch) | |
tree | db251863e50a5f8a4e5e3e637b61388b13813d0c /doc | |
parent | dc7cd071db50334beae6cf141bb4781085d8b303 (diff) | |
download | tcl-63d86fb9f3f115b84b724d53884f8df7b7fa82fb.zip tcl-63d86fb9f3f115b84b724d53884f8df7b7fa82fb.tar.gz tcl-63d86fb9f3f115b84b724d53884f8df7b7fa82fb.tar.bz2 |
Added example inspired by TIP#65
Diffstat (limited to 'doc')
-rw-r--r-- | doc/info.n | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -7,7 +7,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: info.n,v 1.9 2004/02/17 04:55:27 hobbs Exp $ +'\" RCS: @(#) $Id: info.n,v 1.10 2004/05/28 10:49:09 dkf Exp $ '\" .so man.macros .TH info n 8.4 Tcl "Tcl Built-In Commands" @@ -202,6 +202,25 @@ has each matching namespace variable qualified with the name of its namespace. Note that a currently-visible variable may not yet "exist" if it has not been set (e.g. a variable declared but not set by \fBvariable\fR). +.SH EXAMPLE +This command prints out a procedure suitable for saving in a Tcl +script: +.CS +proc printProc {procName} { + set result [list proc $procName] + set formals {} + foreach var [info args $procName] { + if {[info default $procName $var def]} { + lappend formals [list $var $def] + } else { + # Still need the list-quoting because variable + # names may properly contain spaces. + lappend formals [list $var] + } + } + puts [lappend result $formals [info body $procName]] +} +.CE .SH "SEE ALSO" global(n), proc(n) |