From 63d86fb9f3f115b84b724d53884f8df7b7fa82fb Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 28 May 2004 10:49:09 +0000 Subject: Added example inspired by TIP#65 --- doc/info.n | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/doc/info.n b/doc/info.n index a652c9d..951f492 100644 --- a/doc/info.n +++ b/doc/info.n @@ -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) -- cgit v0.12