OSDN Git Service

Please enter the commit message for your changes. Lines starting
[eos/hostdependX86LINUX64.git] / util / X86LINUX64 / man / mann / Tcl.n
1 '\"
2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH Tcl n "8.6" Tcl "Tcl Built-In Commands"
9 .\" The -*- nroff -*- definitions below are for supplemental macros used
10 .\" in Tcl/Tk manual entries.
11 .\"
12 .\" .AP type name in/out ?indent?
13 .\"     Start paragraph describing an argument to a library procedure.
14 .\"     type is type of argument (int, etc.), in/out is either "in", "out",
15 .\"     or "in/out" to describe whether procedure reads or modifies arg,
16 .\"     and indent is equivalent to second arg of .IP (shouldn't ever be
17 .\"     needed;  use .AS below instead)
18 .\"
19 .\" .AS ?type? ?name?
20 .\"     Give maximum sizes of arguments for setting tab stops.  Type and
21 .\"     name are examples of largest possible arguments that will be passed
22 .\"     to .AP later.  If args are omitted, default tab stops are used.
23 .\"
24 .\" .BS
25 .\"     Start box enclosure.  From here until next .BE, everything will be
26 .\"     enclosed in one large box.
27 .\"
28 .\" .BE
29 .\"     End of box enclosure.
30 .\"
31 .\" .CS
32 .\"     Begin code excerpt.
33 .\"
34 .\" .CE
35 .\"     End code excerpt.
36 .\"
37 .\" .VS ?version? ?br?
38 .\"     Begin vertical sidebar, for use in marking newly-changed parts
39 .\"     of man pages.  The first argument is ignored and used for recording
40 .\"     the version when the .VS was added, so that the sidebars can be
41 .\"     found and removed when they reach a certain age.  If another argument
42 .\"     is present, then a line break is forced before starting the sidebar.
43 .\"
44 .\" .VE
45 .\"     End of vertical sidebar.
46 .\"
47 .\" .DS
48 .\"     Begin an indented unfilled display.
49 .\"
50 .\" .DE
51 .\"     End of indented unfilled display.
52 .\"
53 .\" .SO ?manpage?
54 .\"     Start of list of standard options for a Tk widget. The manpage
55 .\"     argument defines where to look up the standard options; if
56 .\"     omitted, defaults to "options". The options follow on successive
57 .\"     lines, in three columns separated by tabs.
58 .\"
59 .\" .SE
60 .\"     End of list of standard options for a Tk widget.
61 .\"
62 .\" .OP cmdName dbName dbClass
63 .\"     Start of description of a specific option.  cmdName gives the
64 .\"     option's name as specified in the class command, dbName gives
65 .\"     the option's name in the option database, and dbClass gives
66 .\"     the option's class in the option database.
67 .\"
68 .\" .UL arg1 arg2
69 .\"     Print arg1 underlined, then print arg2 normally.
70 .\"
71 .\" .QW arg1 ?arg2?
72 .\"     Print arg1 in quotes, then arg2 normally (for trailing punctuation).
73 .\"
74 .\" .PQ arg1 ?arg2?
75 .\"     Print an open parenthesis, arg1 in quotes, then arg2 normally
76 .\"     (for trailing punctuation) and then a closing parenthesis.
77 .\"
78 .\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
79 .if t .wh -1.3i ^B
80 .nr ^l \n(.l
81 .ad b
82 .\"     # Start an argument description
83 .de AP
84 .ie !"\\$4"" .TP \\$4
85 .el \{\
86 .   ie !"\\$2"" .TP \\n()Cu
87 .   el          .TP 15
88 .\}
89 .ta \\n()Au \\n()Bu
90 .ie !"\\$3"" \{\
91 \&\\$1 \\fI\\$2\\fP (\\$3)
92 .\".b
93 .\}
94 .el \{\
95 .br
96 .ie !"\\$2"" \{\
97 \&\\$1  \\fI\\$2\\fP
98 .\}
99 .el \{\
100 \&\\fI\\$1\\fP
101 .\}
102 .\}
103 ..
104 .\"     # define tabbing values for .AP
105 .de AS
106 .nr )A 10n
107 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
108 .nr )B \\n()Au+15n
109 .\"
110 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
111 .nr )C \\n()Bu+\\w'(in/out)'u+2n
112 ..
113 .AS Tcl_Interp Tcl_CreateInterp in/out
114 .\"     # BS - start boxed text
115 .\"     # ^y = starting y location
116 .\"     # ^b = 1
117 .de BS
118 .br
119 .mk ^y
120 .nr ^b 1u
121 .if n .nf
122 .if n .ti 0
123 .if n \l'\\n(.lu\(ul'
124 .if n .fi
125 ..
126 .\"     # BE - end boxed text (draw box now)
127 .de BE
128 .nf
129 .ti 0
130 .mk ^t
131 .ie n \l'\\n(^lu\(ul'
132 .el \{\
133 .\"     Draw four-sided box normally, but don't draw top of
134 .\"     box if the box started on an earlier page.
135 .ie !\\n(^b-1 \{\
136 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
137 .\}
138 .el \}\
139 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
140 .\}
141 .\}
142 .fi
143 .br
144 .nr ^b 0
145 ..
146 .\"     # VS - start vertical sidebar
147 .\"     # ^Y = starting y location
148 .\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
149 .de VS
150 .if !"\\$2"" .br
151 .mk ^Y
152 .ie n 'mc \s12\(br\s0
153 .el .nr ^v 1u
154 ..
155 .\"     # VE - end of vertical sidebar
156 .de VE
157 .ie n 'mc
158 .el \{\
159 .ev 2
160 .nf
161 .ti 0
162 .mk ^t
163 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
164 .sp -1
165 .fi
166 .ev
167 .\}
168 .nr ^v 0
169 ..
170 .\"     # Special macro to handle page bottom:  finish off current
171 .\"     # box/sidebar if in box/sidebar mode, then invoked standard
172 .\"     # page bottom macro.
173 .de ^B
174 .ev 2
175 'ti 0
176 'nf
177 .mk ^t
178 .if \\n(^b \{\
179 .\"     Draw three-sided box if this is the box's first page,
180 .\"     draw two sides but no top otherwise.
181 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
182 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
183 .\}
184 .if \\n(^v \{\
185 .nr ^x \\n(^tu+1v-\\n(^Yu
186 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
187 .\}
188 .bp
189 'fi
190 .ev
191 .if \\n(^b \{\
192 .mk ^y
193 .nr ^b 2
194 .\}
195 .if \\n(^v \{\
196 .mk ^Y
197 .\}
198 ..
199 .\"     # DS - begin display
200 .de DS
201 .RS
202 .nf
203 .sp
204 ..
205 .\"     # DE - end display
206 .de DE
207 .fi
208 .RE
209 .sp
210 ..
211 .\"     # SO - start of list of standard options
212 .de SO
213 'ie '\\$1'' .ds So \\fBoptions\\fR
214 'el .ds So \\fB\\$1\\fR
215 .SH "STANDARD OPTIONS"
216 .LP
217 .nf
218 .ta 5.5c 11c
219 .ft B
220 ..
221 .\"     # SE - end of list of standard options
222 .de SE
223 .fi
224 .ft R
225 .LP
226 See the \\*(So manual entry for details on the standard options.
227 ..
228 .\"     # OP - start of full description for a single option
229 .de OP
230 .LP
231 .nf
232 .ta 4c
233 Command-Line Name:      \\fB\\$1\\fR
234 Database Name:  \\fB\\$2\\fR
235 Database Class: \\fB\\$3\\fR
236 .fi
237 .IP
238 ..
239 .\"     # CS - begin code excerpt
240 .de CS
241 .RS
242 .nf
243 .ta .25i .5i .75i 1i
244 ..
245 .\"     # CE - end code excerpt
246 .de CE
247 .fi
248 .RE
249 ..
250 .\"     # UL - underline word
251 .de UL
252 \\$1\l'|0\(ul'\\$2
253 ..
254 .\"     # QW - apply quotation marks to word
255 .de QW
256 .ie '\\*(lq'"' ``\\$1''\\$2
257 .\"" fix emacs highlighting
258 .el \\*(lq\\$1\\*(rq\\$2
259 ..
260 .\"     # PQ - apply parens and quotation marks to word
261 .de PQ
262 .ie '\\*(lq'"' (``\\$1''\\$2)\\$3
263 .\"" fix emacs highlighting
264 .el (\\*(lq\\$1\\*(rq\\$2)\\$3
265 ..
266 .\"     # QR - quoted range
267 .de QR
268 .ie '\\*(lq'"' ``\\$1''\\-``\\$2''\\$3
269 .\"" fix emacs highlighting
270 .el \\*(lq\\$1\\*(rq\\-\\*(lq\\$2\\*(rq\\$3
271 ..
272 .\"     # MT - "empty" string
273 .de MT
274 .QW ""
275 ..
276 .BS
277 .SH NAME
278 Tcl \- Tool Command Language
279 .SH SYNOPSIS
280 Summary of Tcl language syntax.
281 .BE
282 .SH DESCRIPTION
283 .PP
284 The following rules define the syntax and semantics of the Tcl language:
285 .IP "[1] \fBCommands.\fR"
286 A Tcl script is a string containing one or more commands.
287 Semi-colons and newlines are command separators unless quoted as
288 described below.
289 Close brackets are command terminators during command substitution
290 (see below) unless quoted.
291 .IP "[2] \fBEvaluation.\fR"
292 A command is evaluated in two steps.
293 First, the Tcl interpreter breaks the command into \fIwords\fR
294 and performs substitutions as described below.
295 These substitutions are performed in the same way for all
296 commands.
297 Secondly, the first word is used to locate a command procedure to
298 carry out the command, then all of the words of the command are
299 passed to the command procedure.
300 The command procedure is free to interpret each of its words
301 in any way it likes, such as an integer, variable name, list,
302 or Tcl script.
303 Different commands interpret their words differently.
304 .IP "[3] \fBWords.\fR"
305 Words of a command are separated by white space (except for
306 newlines, which are command separators).
307 .IP "[4] \fBDouble quotes.\fR"
308 If the first character of a word is double-quote
309 .PQ \N'34'
310 then the word is terminated by the next double-quote character.
311 If semi-colons, close brackets, or white space characters
312 (including newlines) appear between the quotes then they are treated
313 as ordinary characters and included in the word.
314 Command substitution, variable substitution, and backslash substitution
315 are performed on the characters between the quotes as described below.
316 The double-quotes are not retained as part of the word.
317 .IP "[5] \fBArgument expansion.\fR"
318 If a word starts with the string
319 .QW {*}
320 followed by a non-whitespace character, then the leading
321 .QW {*}
322 is removed and the rest of the word is parsed and substituted as any other
323 word. After substitution, the word is parsed as a list (without command or
324 variable substitutions; backslash substitutions are performed as is normal for
325 a list and individual internal words may be surrounded by either braces or
326 double-quote characters), and its words are added to the command being
327 substituted. For instance,
328 .QW "cmd a {*}{b [c]} d {*}{$e f {g h}}"
329 is equivalent to
330 .QW "cmd a b {[c]} d {$e} f {g h}" .
331 .IP "[6] \fBBraces.\fR"
332 If the first character of a word is an open brace
333 .PQ {
334 and rule [5] does not apply, then
335 the word is terminated by the matching close brace
336 .PQ } "" .
337 Braces nest within the word: for each additional open
338 brace there must be an additional close brace (however,
339 if an open brace or close brace within the word is
340 quoted with a backslash then it is not counted in locating the
341 matching close brace).
342 No substitutions are performed on the characters between the
343 braces except for backslash-newline substitutions described
344 below, nor do semi-colons, newlines, close brackets,
345 or white space receive any special interpretation.
346 The word will consist of exactly the characters between the
347 outer braces, not including the braces themselves.
348 .IP "[7] \fBCommand substitution.\fR"
349 If a word contains an open bracket
350 .PQ [
351 then Tcl performs \fIcommand substitution\fR.
352 To do this it invokes the Tcl interpreter recursively to process
353 the characters following the open bracket as a Tcl script.
354 The script may contain any number of commands and must be terminated
355 by a close bracket
356 .PQ ] "" .
357 The result of the script (i.e. the result of its last command) is
358 substituted into the word in place of the brackets and all of the
359 characters between them.
360 There may be any number of command substitutions in a single word.
361 Command substitution is not performed on words enclosed in braces.
362 .IP "[8] \fBVariable substitution.\fR"
363 If a word contains a dollar-sign
364 .PQ $
365 followed by one of the forms
366 described below, then Tcl performs \fIvariable
367 substitution\fR:  the dollar-sign and the following characters are
368 replaced in the word by the value of a variable.
369 Variable substitution may take any of the following forms:
370 .RS
371 .TP 15
372 \fB$\fIname\fR
373 .
374 \fIName\fR is the name of a scalar variable;  the name is a sequence
375 of one or more characters that are a letter, digit, underscore,
376 or namespace separators (two or more colons).
377 Letters and digits are \fIonly\fR the standard ASCII ones (\fB0\fR\(en\fB9\fR,
378 \fBA\fR\(en\fBZ\fR and \fBa\fR\(en\fBz\fR).
379 .TP 15
380 \fB$\fIname\fB(\fIindex\fB)\fR
381 .
382 \fIName\fR gives the name of an array variable and \fIindex\fR gives
383 the name of an element within that array.
384 \fIName\fR must contain only letters, digits, underscores, and
385 namespace separators, and may be an empty string.
386 Letters and digits are \fIonly\fR the standard ASCII ones (\fB0\fR\(en\fB9\fR,
387 \fBA\fR\(en\fBZ\fR and \fBa\fR\(en\fBz\fR).
388 Command substitutions, variable substitutions, and backslash
389 substitutions are performed on the characters of \fIindex\fR.
390 .TP 15
391 \fB${\fIname\fB}\fR
392 .
393 \fIName\fR is the name of a scalar variable or array element.  It may contain
394 any characters whatsoever except for close braces.  It indicates an array
395 element if \fIname\fR is in the form
396 .QW \fIarrayName\fB(\fIindex\fB)\fR
397 where \fIarrayName\fR does not contain any open parenthesis characters,
398 .QW \fB(\fR ,
399 or close brace characters,
400 .QW \fB}\fR ,
401 and \fIindex\fR can be any sequence of characters except for close brace
402 characters.  No further
403 substitutions are performed during the parsing of \fIname\fR.
404 .PP
405 There may be any number of variable substitutions in a single word.
406 Variable substitution is not performed on words enclosed in braces.
407 .PP
408 Note that variables may contain character sequences other than those listed
409 above, but in that case other mechanisms must be used to access them (e.g.,
410 via the \fBset\fR command's single-argument form).
411 .RE
412 .IP "[9] \fBBackslash substitution.\fR"
413 If a backslash
414 .PQ \e
415 appears within a word then \fIbackslash substitution\fR occurs.
416 In all cases but those described below the backslash is dropped and
417 the following character is treated as an ordinary
418 character and included in the word.
419 This allows characters such as double quotes, close brackets,
420 and dollar signs to be included in words without triggering
421 special processing.
422 The following table lists the backslash sequences that are
423 handled specially, along with the value that replaces each sequence.
424 .RS
425 .TP 7
426 \e\fBa\fR
427 Audible alert (bell) (Unicode U+000007).
428 .TP 7
429 \e\fBb\fR
430 Backspace (Unicode U+000008).
431 .TP 7
432 \e\fBf\fR
433 Form feed (Unicode U+00000C).
434 .TP 7
435 \e\fBn\fR
436 Newline (Unicode U+00000A).
437 .TP 7
438 \e\fBr\fR
439 Carriage-return (Unicode U+00000D).
440 .TP 7
441 \e\fBt\fR
442 Tab (Unicode U+000009).
443 .TP 7
444 \e\fBv\fR
445 Vertical tab (Unicode U+00000B).
446 .TP 7
447 \e\fB<newline>\fIwhiteSpace\fR
448 .
449 A single space character replaces the backslash, newline, and all spaces
450 and tabs after the newline.  This backslash sequence is unique in that it
451 is replaced in a separate pre-pass before the command is actually parsed.
452 This means that it will be replaced even when it occurs between braces,
453 and the resulting space will be treated as a word separator if it is not
454 in braces or quotes.
455 .TP 7
456 \e\e
457 Backslash
458 .PQ \e "" .
459 .TP 7
460 \e\fIooo\fR 
461 .
462 The digits \fIooo\fR (one, two, or three of them) give a eight-bit octal 
463 value for the Unicode character that will be inserted, in the range
464 \fI000\fR\(en\fI377\fR (i.e., the range U+000000\(enU+0000FF).
465 The parser will stop just before this range overflows, or when
466 the maximum of three digits is reached.  The upper bits of the Unicode
467 character will be 0.
468 .TP 7
469 \e\fBx\fIhh\fR 
470 .
471 The hexadecimal digits \fIhh\fR (one or two of them) give an eight-bit
472 hexadecimal value for the Unicode character that will be inserted.  The upper
473 bits of the Unicode character will be 0 (i.e., the character will be in the
474 range U+000000\(enU+0000FF).
475 .TP 7
476 \e\fBu\fIhhhh\fR 
477 .
478 The hexadecimal digits \fIhhhh\fR (one, two, three, or four of them) give a
479 sixteen-bit hexadecimal value for the Unicode character that will be
480 inserted.  The upper bits of the Unicode character will be 0 (i.e., the
481 character will be in the range U+000000\(enU+00FFFF).
482 .TP 7
483 \e\fBU\fIhhhhhhhh\fR 
484 .
485 The hexadecimal digits \fIhhhhhhhh\fR (one up to eight of them) give a
486 twenty-one-bit hexadecimal value for the Unicode character that will be
487 inserted, in the range U+000000\(enU+10FFFF.  The parser will stop just
488 before this range overflows, or when the maximum of eight digits
489 is reached.  The upper bits of the Unicode character will be 0.
490 .RS
491 .PP
492 The range U+010000\(enU+10FFFD is reserved for the future.
493 .RE
494 .PP
495 Backslash substitution is not performed on words enclosed in braces,
496 except for backslash-newline as described above.
497 .RE
498 .IP "[10] \fBComments.\fR"
499 If a hash character
500 .PQ #
501 appears at a point where Tcl is
502 expecting the first character of the first word of a command,
503 then the hash character and the characters that follow it, up
504 through the next newline, are treated as a comment and ignored.
505 The comment character only has significance when it appears
506 at the beginning of a command.
507 .IP "[11] \fBOrder of substitution.\fR"
508 Each character is processed exactly once by the Tcl interpreter
509 as part of creating the words of a command.
510 For example, if variable substitution occurs then no further
511 substitutions are performed on the value of the variable;  the
512 value is inserted into the word verbatim.
513 If command substitution occurs then the nested command is
514 processed entirely by the recursive call to the Tcl interpreter;
515 no substitutions are performed before making the recursive
516 call and no additional substitutions are performed on the result
517 of the nested script.
518 .RS
519 .PP
520 Substitutions take place from left to right, and each substitution is
521 evaluated completely before attempting to evaluate the next.  Thus, a
522 sequence like
523 .PP
524 .CS
525 set y [set x 0][incr x][incr x]
526 .CE
527 .PP
528 will always set the variable \fIy\fR to the value, \fI012\fR.
529 .RE
530 .IP "[12] \fBSubstitution and word boundaries.\fR"
531 Substitutions do not affect the word boundaries of a command,
532 except for argument expansion as specified in rule [5].
533 For example, during variable substitution the entire value of
534 the variable becomes part of a single word, even if the variable's
535 value contains spaces.
536 .SH KEYWORDS
537 backslash, command, comment, script, substitution, variable
538 '\" Local Variables:
539 '\" mode: nroff
540 '\" fill-column: 78
541 '\" End: