Tcl Source Code

Check-in [7c568a9106]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:* doc/dict.n (dict with): [Bug 3474512]: Explain better what is going on when a dictionary key and the dictionary variable collide.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-5-branch
Files: files | file ages | folders
SHA1: 7c568a91064930a398e7ea8345c80b616345cc90
User & Date: dkf 2012-01-17 15:17:21
Context
2012-01-21
08:19
Prevent buffer read overflow. Thanks to "sebres" for the report and fix. check-in: 03cb2cb9ed user: jan.nijtmans tags: core-8-5-branch
2012-01-17
15:22
* doc/dict.n (dict with): [Bug 3474512]: Explain better what is going on when a dictionary key and t... check-in: 18138fd96f user: dkf tags: trunk
15:17
* doc/dict.n (dict with): [Bug 3474512]: Explain better what is going on when a dictionary key and t... check-in: 7c568a9106 user: dkf tags: core-8-5-branch
14:32
Bump to version 2.7.8 check-in: ba7ac32678 user: dgp tags: core-8-5-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.






1
2
3
4
5
6
7





2012-01-17  Don Porter  <[email protected]>

	* library/http/http.tcl:	Bump to version 2.7.8
	* library/http/pkgIndex.tcl:
	* unix/Makefile.in:
	* win/Makefile.in:

>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
2012-01-17  Donal K. Fellows  <[email protected]>

	* doc/dict.n (dict with): [Bug 3474512]: Explain better what is going
	on when a dictionary key and the dictionary variable collide.

2012-01-17  Don Porter  <[email protected]>

	* library/http/http.tcl:	Bump to version 2.7.8
	* library/http/pkgIndex.tcl:
	* unix/Makefile.in:
	* win/Makefile.in:

Changes to doc/dict.n.

223
224
225
226
227
228
229









230
231
232
233
234
235
236
it is recommended that this command only be used in a local scope
(\fBproc\fRedure or lambda term for \fBapply\fR). Because of
this, the variables set by \fBdict with\fR will continue to
exist after the command finishes (unless explicitly \fBunset\fR).
Note that the mapping of values to variables does not use
traces; changes to the \fIdictionaryVariable\fR's contents only happen
when \fIbody\fR terminates.









.RE
.SH "DICTIONARY VALUES"
.PP
Dictionaries are values that contain an efficient, order-preserving
mapping from arbitrary keys to arbitrary values.
Each key in the dictionary maps to a single value.
They have a textual format that is exactly that of any list with an







>
>
>
>
>
>
>
>
>







223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
it is recommended that this command only be used in a local scope
(\fBproc\fRedure or lambda term for \fBapply\fR). Because of
this, the variables set by \fBdict with\fR will continue to
exist after the command finishes (unless explicitly \fBunset\fR).
Note that the mapping of values to variables does not use
traces; changes to the \fIdictionaryVariable\fR's contents only happen
when \fIbody\fR terminates.
.PP
If the \fIdictionaryVariable\fR contains a value that is not a dictionary at
the point when the \fIbody\fR terminates (which can easily happen if the name
is the same as any of the keys in dictionary) then an error occurs at that
point. This command is thus not recommended for use when the keys in the
dictionary are expected to clash with the \fIdictionaryVariable\fR name
itself. Where the contained key does map to a dictionary, the net effect is to
combine that inner dictionary into the outer dictionary; see the
\fBEXAMPLES\fR below for an illustration of this.
.RE
.SH "DICTIONARY VALUES"
.PP
Dictionaries are values that contain an efficient, order-preserving
mapping from arbitrary keys to arbitrary values.
Each key in the dictionary maps to a single value.
They have a textual format that is exactly that of any list with an
360
361
362
363
364
365
366










367
368
369
370

sumDictionary myDict
#    prints: \fIlast total was 15, for key b\fR

puts "dictionary is now \\"$myDict\\""
#    prints: \fIdictionary is now "a {total 6} b {total 15}"\fR
.CE










.SH "SEE ALSO"
append(n), array(n), foreach(n), incr(n), list(n), lappend(n), set(n)
.SH KEYWORDS
dictionary, create, update, lookup, iterate, filter







>
>
>
>
>
>
>
>
>
>




369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389

sumDictionary myDict
#    prints: \fIlast total was 15, for key b\fR

puts "dictionary is now \\"$myDict\\""
#    prints: \fIdictionary is now "a {total 6} b {total 15}"\fR
.CE
.PP
When \fBdict with\fR is used with a key that clashes with the name of the
dictionary variable:
.PP
.CS
set foo {foo {a b} bar 2 baz 3}
\fBdict with\fR foo {}
puts $foo
#    prints: \fIa b foo {a b} bar 2 baz 3\fR
.CE
.SH "SEE ALSO"
append(n), array(n), foreach(n), incr(n), list(n), lappend(n), set(n)
.SH KEYWORDS
dictionary, create, update, lookup, iterate, filter