Wiki page
[Migrating scripts to Tcl 9] by
apnadkarni
2024-06-18 02:38:56.
0000: 44 20 32 30 32 34 2d 30 36 2d 31 38 54 30 32 3a D 2024-06-18T02:
0010: 33 38 3a 35 36 2e 35 38 39 0a 4c 20 4d 69 67 72 38:56.589.L Migr
0020: 61 74 69 6e 67 5c 73 73 63 72 69 70 74 73 5c 73 ating\sscripts\s
0030: 74 6f 5c 73 54 63 6c 5c 73 39 0a 4e 20 74 65 78 to\sTcl\s9.N tex
0040: 74 2f 78 2d 6d 61 72 6b 64 6f 77 6e 0a 50 20 62 t/x-markdown.P b
0050: 34 30 62 61 39 33 31 30 35 39 62 36 34 31 35 38 40ba931059b64158
0060: 63 31 37 61 63 30 36 32 62 37 65 31 31 31 30 32 c17ac062b7e11102
0070: 39 37 39 30 33 31 38 30 31 38 30 62 66 62 32 62 97903180180bfb2b
0080: 33 33 66 35 64 33 64 30 34 30 65 63 33 65 62 0a 33f5d3d040ec3eb.
0090: 55 20 61 70 6e 61 64 6b 61 72 6e 69 0a 57 20 31 U apnadkarni.W 1
00a0: 38 39 31 35 0a 57 6f 72 6b 20 69 6e 20 70 72 6f 8915.Work in pro
00b0: 67 72 65 73 73 2e 2e 2e 0d 0a 43 75 72 72 65 6e gress.....Curren
00c0: 74 6c 79 20 66 6f 63 75 73 65 64 20 6f 6e 20 69 tly focused on i
00d0: 6e 63 6f 6d 70 61 74 69 62 69 6c 69 74 69 65 73 ncompatibilities
00e0: 2e 20 50 6f 73 73 69 62 6c 79 20 68 69 6e 74 73 . Possibly hints
00f0: 20 6f 6e 20 69 6d 70 72 6f 76 69 6e 67 0d 0a 73 on improving..s
0100: 63 72 69 70 74 73 20 6d 61 6b 69 6e 67 20 75 73 cripts making us
0110: 65 20 6f 66 20 6e 65 77 20 66 61 63 69 6c 69 74 e of new facilit
0120: 69 65 73 20 63 6f 75 6c 64 20 62 65 20 61 64 64 ies could be add
0130: 65 64 20 61 74 20 73 6f 6d 65 20 70 6f 69 6e 74 ed at some point
0140: 0d 0a 0d 0a 23 23 20 53 74 72 69 63 74 20 68 61 ....## Strict ha
0150: 6e 64 6c 69 6e 67 20 6f 66 20 69 6c 6c 2d 66 6f ndling of ill-fo
0160: 72 6d 65 64 20 65 6e 63 6f 64 65 64 20 64 61 74 rmed encoded dat
0170: 61 0d 0a 0d 0a 43 6f 6e 63 65 70 74 75 61 6c 6c a....Conceptuall
0180: 79 2c 20 54 63 6c 20 73 74 72 69 6e 67 73 20 61 y, Tcl strings a
0190: 72 65 20 61 20 73 65 71 75 65 6e 63 65 20 6f 66 re a sequence of
01a0: 20 55 6e 69 63 6f 64 65 20 63 6f 64 65 20 70 6f Unicode code po
01b0: 69 6e 74 73 2e 20 54 68 65 73 65 20 73 74 72 69 ints. These stri
01c0: 6e 67 73 0d 0a 61 72 65 20 63 6f 6e 76 65 72 74 ngs..are convert
01d0: 65 64 20 74 6f 20 61 6e 64 20 66 72 6f 6d 20 65 ed to and from e
01e0: 78 74 65 72 6e 61 6c 20 65 6e 63 6f 64 69 6e 67 xternal encoding
01f0: 73 20 76 69 61 20 63 68 61 6e 6e 65 6c 20 49 2f s via channel I/
0200: 4f 20 6f 72 20 65 78 70 6c 69 63 69 74 20 75 73 O or explicit us
0210: 65 20 6f 66 0d 0a 74 68 65 20 60 65 6e 63 6f 64 e of..the `encod
0220: 69 6e 67 60 20 63 6f 6d 6d 61 6e 64 2e 20 54 68 ing` command. Th
0230: 65 20 62 65 68 61 76 69 6f 72 20 6f 66 20 54 63 e behavior of Tc
0240: 6c 20 68 61 73 20 63 68 61 6e 67 65 64 20 69 6e l has changed in
0250: 20 54 63 6c 20 39 20 69 6e 20 74 68 65 20 70 72 Tcl 9 in the pr
0260: 65 73 65 6e 63 65 0d 0a 6f 66 20 69 6c 6c 2d 66 esence..of ill-f
0270: 6f 72 6d 65 64 20 65 6e 63 6f 64 65 64 20 64 61 ormed encoded da
0280: 74 61 20 69 6e 20 69 6e 70 75 74 20 73 74 72 65 ta in input stre
0290: 61 6d 73 20 6f 72 20 69 66 20 6f 75 74 70 75 74 ams or if output
02a0: 20 73 74 72 65 61 6d 73 20 65 6e 63 6f 64 69 6e streams encodin
02b0: 67 73 20 64 6f 0d 0a 6e 6f 74 20 73 75 70 70 6f gs do..not suppo
02c0: 72 74 20 74 68 65 20 55 6e 69 63 6f 64 65 20 63 rt the Unicode c
02d0: 6f 64 65 20 70 6f 69 6e 74 20 62 65 69 6e 67 20 ode point being
02e0: 77 72 69 74 74 65 6e 2e 0d 0a 0d 0a 49 6e 20 74 written.....In t
02f0: 68 65 20 63 61 73 65 20 6f 66 20 69 6e 70 75 74 he case of input
0300: 20 63 68 61 6e 6e 65 6c 73 2c 20 54 63 6c 20 38 channels, Tcl 8
0310: 20 77 6f 75 6c 64 20 73 69 6c 65 6e 74 6c 79 20 would silently
0320: 6d 61 70 20 69 6e 76 61 6c 69 64 20 62 79 74 65 map invalid byte
0330: 73 20 69 6e 20 74 68 65 0d 0a 73 74 72 65 61 6d s in the..stream
0340: 20 74 6f 20 74 68 65 20 6e 75 6d 65 72 69 63 61 to the numerica
0350: 6c 6c 79 20 65 71 75 69 76 61 6c 65 6e 74 20 55 lly equivalent U
0360: 6e 69 63 6f 64 65 20 63 6f 64 65 20 70 6f 69 6e nicode code poin
0370: 74 73 2c 20 69 6e 20 65 73 73 65 6e 63 65 20 70 ts, in essence p
0380: 72 65 73 75 6d 69 6e 67 0d 0a 69 73 6f 38 38 35 resuming..iso885
0390: 39 2d 31 20 65 6e 63 6f 64 69 6e 67 2e 20 4f 6e 9-1 encoding. On
03a0: 20 6f 75 74 70 75 74 20 73 74 72 65 61 6d 73 2c output streams,
03b0: 20 63 68 61 72 61 63 74 65 72 73 20 6e 6f 74 20 characters not
03c0: 73 75 70 70 6f 72 74 65 64 20 62 79 20 74 68 65 supported by the
03d0: 20 6f 75 74 70 75 74 0d 0a 65 6e 63 6f 64 69 6e output..encodin
03e0: 67 20 77 65 72 65 20 73 75 62 73 74 69 74 75 74 g were substitut
03f0: 65 64 20 77 69 74 68 20 61 6e 20 65 6e 63 6f 64 ed with an encod
0400: 69 6e 67 2d 73 70 65 63 69 66 69 63 20 72 65 70 ing-specific rep
0410: 6c 61 63 65 6d 65 6e 74 20 63 68 61 72 61 63 74 lacement charact
0420: 65 72 2e 0d 0a 0d 0a 49 6e 20 63 6f 6e 74 72 61 er.....In contra
0430: 73 74 2c 20 63 68 61 6e 6e 65 6c 73 20 69 6e 20 st, channels in
0440: 54 63 6c 20 39 20 61 72 65 20 62 79 20 64 65 66 Tcl 9 are by def
0450: 61 75 6c 74 20 63 6f 6e 66 69 67 75 72 65 64 20 ault configured
0460: 77 69 74 68 20 74 68 65 20 60 73 74 72 69 63 74 with the `strict
0470: 60 0d 0a 65 6e 63 6f 64 69 6e 67 20 70 72 6f 66 `..encoding prof
0480: 69 6c 65 20 61 6e 64 20 77 69 6c 6c 20 72 61 69 ile and will rai
0490: 73 65 20 61 6e 20 65 72 72 6f 72 20 65 78 63 65 se an error exce
04a0: 70 74 69 6f 6e 20 66 6f 72 20 62 6f 74 68 20 74 ption for both t
04b0: 68 65 20 61 62 6f 76 65 20 63 61 73 65 73 2e 20 he above cases.
04c0: 49 66 0d 0a 54 63 6c 20 38 20 62 65 68 61 76 69 If..Tcl 8 behavi
04d0: 6f 72 20 69 73 20 64 65 73 69 72 65 64 2c 20 61 or is desired, a
04e0: 70 70 6c 69 63 61 74 69 6f 6e 73 20 63 61 6e 20 pplications can
04f0: 75 73 65 20 74 68 65 20 60 2d 70 72 6f 66 69 6c use the `-profil
0500: 65 60 20 6f 70 74 69 6f 6e 20 74 6f 0d 0a 60 66 e` option to..`f
0510: 63 6f 6e 66 69 67 75 72 65 60 20 74 6f 20 61 70 configure` to ap
0520: 70 6c 79 20 74 68 65 20 60 74 63 6c 38 60 20 65 ply the `tcl8` e
0530: 6e 63 6f 64 69 6e 67 20 70 72 6f 66 69 6c 65 20 ncoding profile
0540: 74 6f 20 74 68 65 20 63 68 61 6e 6e 65 6c 2e 20 to the channel.
0550: 54 68 69 73 20 69 73 20 6e 6f 74 0d 0a 72 65 63 This is not..rec
0560: 6f 6d 6d 65 6e 64 65 64 20 61 73 20 69 74 20 69 ommended as it i
0570: 73 20 6e 6f 74 20 73 74 61 6e 64 61 72 64 73 2d s not standards-
0580: 63 6f 6d 70 6c 69 61 6e 74 20 61 6e 64 20 63 61 compliant and ca
0590: 6e 20 62 65 20 73 65 65 6e 20 61 73 20 63 6f 72 n be seen as cor
05a0: 72 75 70 74 69 6e 67 20 64 61 74 61 2e 0d 0a 49 rupting data...I
05b0: 6e 73 74 65 61 64 2c 20 61 20 73 74 61 6e 64 61 nstead, a standa
05c0: 72 64 73 2d 63 6f 6d 70 6c 69 61 6e 74 20 61 6c rds-compliant al
05d0: 74 65 72 6e 61 74 69 76 65 20 69 73 20 74 6f 20 ternative is to
05e0: 75 73 65 20 74 68 65 20 60 72 65 70 6c 61 63 65 use the `replace
05f0: 60 20 70 72 6f 66 69 6c 65 20 77 68 69 63 68 0d ` profile which.
0600: 0a 6c 69 6b 65 20 74 68 65 20 60 74 63 6c 38 60 .like the `tcl8`
0610: 20 70 72 6f 66 69 6c 65 20 77 69 6c 6c 20 61 6c profile will al
0620: 73 6f 20 6e 6f 74 20 72 61 69 73 65 20 65 72 72 so not raise err
0630: 6f 72 73 20 69 6e 20 74 68 65 20 70 72 65 73 65 ors in the prese
0640: 6e 63 65 20 6f 66 20 69 6e 76 61 6c 69 64 6c 79 nce of invalidly
0650: 0d 0a 65 6e 63 6f 64 65 64 20 64 61 74 61 2e 0d ..encoded data..
0660: 0a 0d 0a 54 68 65 20 73 61 6d 65 20 62 65 68 61 ...The same beha
0670: 76 69 6f 75 72 61 6c 20 63 68 61 6e 67 65 73 20 vioural changes
0680: 61 6c 73 6f 20 61 70 70 6c 79 20 74 6f 20 65 78 also apply to ex
0690: 70 6c 69 63 69 74 20 74 72 61 6e 73 66 6f 72 6d plicit transform
06a0: 73 20 77 69 74 68 20 74 68 65 0d 0a 60 65 6e 63 s with the..`enc
06b0: 6f 64 69 6e 67 60 20 63 6f 6d 6d 61 6e 64 2e 20 oding` command.
06c0: 49 6c 6c 20 66 6f 72 6d 65 64 20 64 61 74 61 20 Ill formed data
06d0: 6f 72 20 75 6e 73 75 70 70 6f 72 74 65 64 20 63 or unsupported c
06e0: 68 61 72 61 63 74 65 72 73 20 77 69 6c 6c 20 72 haracters will r
06f0: 65 73 75 6c 74 20 69 6e 20 61 6e 0d 0a 65 72 72 esult in an..err
0700: 6f 72 20 65 78 63 65 70 74 69 6f 6e 2e 20 54 68 or exception. Th
0710: 65 20 60 2d 70 72 6f 66 69 6c 65 60 20 6f 70 74 e `-profile` opt
0720: 69 6f 6e 20 63 61 6e 20 62 65 20 75 73 65 64 20 ion can be used
0730: 69 6e 20 74 68 69 73 20 63 61 73 65 20 61 73 20 in this case as
0740: 77 65 6c 6c 20 74 6f 0d 0a 63 68 61 6e 67 65 20 well to..change
0750: 74 68 69 73 20 62 65 68 61 76 69 6f 72 2e 0d 0a this behavior...
0760: 0d 0a 46 6f 72 20 6d 6f 72 65 20 6f 6e 20 65 6e ..For more on en
0770: 63 6f 64 69 6e 67 20 70 72 6f 66 69 6c 65 73 2c coding profiles,
0780: 20 72 65 66 65 72 20 74 6f 20 74 68 65 20 60 65 refer to the `e
0790: 6e 63 6f 64 69 6e 67 60 20 6d 61 6e 70 61 67 65 ncoding` manpage
07a0: 2e 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 20 36 35 .....See [TIP 65
07b0: 37 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 7](https://core.
07c0: 74 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 tcl-lang.org/tip
07d0: 73 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f s/doc/trunk/tip/
07e0: 36 35 37 2e 6d 64 29 2e 0d 0a 0d 0a 0d 0a 0d 0a 657.md).........
07f0: 23 23 20 54 69 6c 64 65 20 73 75 62 73 74 69 74 ## Tilde substit
0800: 75 74 69 6f 6e 0d 0a 0d 0a 46 69 6c 65 20 70 61 ution....File pa
0810: 74 68 20 61 72 67 75 6d 65 6e 74 73 20 69 6e 20 th arguments in
0820: 54 63 6c 20 38 20 77 6f 75 6c 64 20 62 65 20 73 Tcl 8 would be s
0830: 75 62 6a 65 63 74 20 74 6f 20 74 69 6c 64 65 20 ubject to tilde
0840: 73 75 62 73 74 69 74 75 74 69 6f 6e 0d 0a 77 68 substitution..wh
0850: 65 72 65 20 60 7e 60 20 61 6e 64 20 60 7e 55 53 ere `~` and `~US
0860: 45 52 60 20 70 72 65 66 69 78 65 73 20 69 6e 20 ER` prefixes in
0870: 74 68 65 20 70 61 74 68 20 77 6f 75 6c 64 20 62 the path would b
0880: 65 20 72 65 70 6c 61 63 65 64 20 77 69 74 68 20 e replaced with
0890: 74 68 65 0d 0a 68 6f 6d 65 20 64 69 72 65 63 74 the..home direct
08a0: 6f 72 79 20 6f 66 20 74 68 65 20 63 75 72 72 65 ory of the curre
08b0: 6e 74 20 6f 72 20 6e 61 6d 65 64 20 75 73 65 72 nt or named user
08c0: 20 72 65 73 70 65 63 74 69 76 65 6c 79 2e 20 41 respectively. A
08d0: 6c 74 68 6f 75 67 68 0d 0a 63 6f 6e 76 65 6e 69 lthough..conveni
08e0: 65 6e 74 20 66 6f 72 20 69 6e 74 65 72 61 63 74 ent for interact
08f0: 69 76 65 20 75 73 65 2c 20 74 68 69 73 20 62 65 ive use, this be
0900: 68 61 76 69 6f 72 20 6c 65 61 64 20 74 6f 20 62 havior lead to b
0910: 6f 74 68 20 73 65 63 75 72 69 74 79 20 61 6e 64 oth security and
0920: 0d 0a 72 6f 62 75 73 74 6e 65 73 73 20 69 73 73 ..robustness iss
0930: 75 65 73 20 61 73 20 64 6f 63 75 6d 65 6e 74 65 ues as documente
0940: 64 20 69 6e 20 54 49 50 20 36 30 32 2e 0d 0a 0d d in TIP 602....
0950: 0a 54 63 6c 20 39 20 74 68 65 72 65 66 6f 72 65 .Tcl 9 therefore
0960: 20 6e 6f 20 6c 6f 6e 67 65 72 20 64 6f 65 73 20 no longer does
0970: 74 68 69 73 20 73 75 62 73 74 69 74 75 74 69 6f this substitutio
0980: 6e 20 61 6e 64 20 73 63 72 69 70 74 73 20 6d 75 n and scripts mu
0990: 73 74 0d 0a 65 78 70 6c 69 63 69 74 6c 79 20 64 st..explicitly d
09a0: 6f 20 74 68 65 20 73 61 6d 65 20 69 66 20 64 65 o the same if de
09b0: 73 69 72 65 64 20 77 69 74 68 20 74 68 65 20 6e sired with the n
09c0: 65 77 20 63 6f 6d 6d 61 6e 64 73 20 60 66 69 6c ew commands `fil
09d0: 65 20 68 6f 6d 65 60 20 61 6e 64 0d 0a 60 66 69 e home` and..`fi
09e0: 6c 65 20 74 69 6c 64 65 65 78 70 61 6e 64 60 2e le tildeexpand`.
09f0: 20 43 6f 6e 76 65 72 73 65 6c 79 2c 20 63 6f 6d Conversely, com
0a00: 6d 61 6e 64 73 20 74 68 61 74 20 68 61 64 20 74 mands that had t
0a10: 6f 20 70 72 6f 74 65 63 74 20 61 67 61 69 6e 73 o protect agains
0a20: 74 0d 0a 74 68 69 73 20 74 72 65 61 74 6d 65 6e t..this treatmen
0a30: 74 20 6f 66 20 60 7e 60 20 62 79 20 70 72 65 66 t of `~` by pref
0a40: 69 78 69 6e 67 20 77 69 74 68 20 60 2e 2f 60 20 ixing with `./`
0a50: 28 60 67 6c 6f 62 60 2c 20 60 66 69 6c 65 20 73 (`glob`, `file s
0a60: 70 6c 69 74 60 20 65 74 63 2e 29 0d 0a 77 69 6c plit` etc.)..wil
0a70: 6c 20 6e 6f 20 6c 6f 6e 67 65 72 20 74 6f 20 64 l no longer to d
0a80: 6f 20 73 6f 2e 20 53 63 72 69 70 74 73 20 74 68 o so. Scripts th
0a90: 61 74 20 68 61 64 20 74 68 65 69 72 20 6f 77 6e at had their own
0aa0: 20 77 6f 72 6b 61 72 6f 75 6e 64 73 20 74 6f 0d workarounds to.
0ab0: 0a 70 72 6f 74 65 63 74 20 61 67 61 69 6e 73 74 .protect against
0ac0: 20 74 69 6c 64 65 20 73 75 62 73 74 69 74 75 74 tilde substitut
0ad0: 69 6f 6e 20 6e 6f 20 6c 6f 6e 67 65 72 20 6e 65 ion no longer ne
0ae0: 65 64 20 74 6f 20 64 6f 20 73 6f 2e 0d 0a 0d 0a ed to do so.....
0af0: 41 73 20 61 6e 20 65 78 63 65 70 74 69 6f 6e 20 As an exception
0b00: 66 6f 72 20 63 6f 6e 76 65 6e 69 65 6e 63 65 20 for convenience
0b10: 66 6f 72 20 65 6e 64 20 75 73 65 72 73 2c 20 74 for end users, t
0b20: 69 6c 64 65 20 73 75 62 73 74 69 74 75 74 69 6f ilde substitutio
0b30: 6e 20 69 73 0d 0a 73 74 69 6c 6c 20 64 6f 6e 65 n is..still done
0b40: 20 61 74 20 73 74 61 72 74 20 75 70 20 74 69 6d at start up tim
0b50: 65 20 6f 6e 20 65 6e 76 69 72 6f 6e 6d 65 6e 74 e on environment
0b60: 20 76 61 6c 75 65 73 20 63 6f 6e 74 61 69 6e 69 values containi
0b70: 6e 67 20 6c 69 62 72 61 72 79 0d 0a 70 61 74 68 ng library..path
0b80: 73 20 28 60 54 43 4c 4c 49 42 50 41 54 48 60 20 s (`TCLLIBPATH`
0b90: 61 6e 64 20 61 6e 61 6c 6f 67 6f 75 73 20 74 6d and analogous tm
0ba0: 20 70 61 74 68 20 76 61 72 69 61 6e 74 73 29 2e path variants).
0bb0: 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 20 36 30 32 ....See [TIP 602
0bc0: 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 74 ](https://core.t
0bd0: 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 73 cl-lang.org/tips
0be0: 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f 36 /doc/trunk/tip/6
0bf0: 30 32 2e 6d 64 29 2e 0d 0a 0d 0a 23 23 20 4f 63 02.md).....## Oc
0c00: 74 61 6c 73 0d 0a 0d 0a 54 68 65 20 54 63 6c 20 tals....The Tcl
0c10: 38 20 69 6e 74 65 70 72 65 74 61 74 69 6f 6e 20 8 intepretation
0c20: 6f 66 20 6e 75 6d 65 72 69 63 20 73 74 72 69 6e of numeric strin
0c30: 67 73 20 62 65 67 69 6e 6e 69 6e 67 20 77 69 74 gs beginning wit
0c40: 68 20 60 30 60 20 61 73 20 6f 63 74 61 6c 0d 0a h `0` as octal..
0c50: 72 65 70 72 65 73 65 6e 74 61 74 69 6f 6e 20 68 representation h
0c60: 61 73 20 62 65 65 6e 20 64 6f 6e 65 20 61 77 61 as been done awa
0c70: 79 20 77 69 74 68 2e 20 54 68 65 73 65 20 61 72 y with. These ar
0c80: 65 20 6e 6f 77 20 74 72 65 61 74 65 64 20 61 73 e now treated as
0c90: 20 64 65 63 69 6d 61 6c 2e 0d 0a 41 6c 6c 20 73 decimal...All s
0ca0: 75 63 68 20 75 73 65 73 20 77 69 74 68 69 6e 20 uch uses within
0cb0: 61 20 73 63 72 69 70 74 20 73 68 6f 75 6c 64 20 a script should
0cc0: 69 6e 73 74 65 61 64 20 75 73 65 20 74 68 65 20 instead use the
0cd0: 65 78 70 6c 69 63 69 74 20 60 30 6f 60 20 70 72 explicit `0o` pr
0ce0: 65 66 69 78 0d 0a 66 6f 72 20 6f 63 74 61 6c 20 efix..for octal
0cf0: 6e 6f 74 61 74 69 6f 6e 2e 20 50 61 72 74 69 63 notation. Partic
0d00: 75 6c 61 72 20 63 61 72 65 20 6d 75 73 74 20 62 ular care must b
0d10: 65 20 74 61 6b 65 6e 20 6f 6e 20 69 6e 70 75 74 e taken on input
0d20: 20 61 6e 64 20 6f 75 74 70 75 74 0d 0a 77 68 65 and output..whe
0d30: 6e 20 69 6e 74 65 72 61 63 74 69 6e 67 20 77 69 n interacting wi
0d40: 74 68 20 70 72 6f 67 72 61 6d 73 20 6f 72 20 75 th programs or u
0d50: 73 65 72 73 20 62 61 73 65 64 20 6f 6e 20 74 68 sers based on th
0d60: 65 20 6f 6c 64 20 69 6e 74 65 72 70 72 65 74 61 e old interpreta
0d70: 74 69 6f 6e 2e 0d 0a 0d 0a 53 65 65 20 5b 54 49 tion.....See [TI
0d80: 50 20 31 31 34 5d 28 68 74 74 70 73 3a 2f 2f 63 P 114](https://c
0d90: 6f 72 65 2e 74 63 6c 2d 6c 61 6e 67 2e 6f 72 67 ore.tcl-lang.org
0da0: 2f 74 69 70 73 2f 64 6f 63 2f 74 72 75 6e 6b 2f /tips/doc/trunk/
0db0: 74 69 70 2f 31 31 34 2e 6d 64 29 2e 0d 0a 0d 0a tip/114.md).....
0dc0: 23 23 20 55 6e 64 65 72 73 63 6f 72 65 73 20 69 ## Underscores i
0dd0: 6e 20 69 6e 74 65 67 65 72 73 0d 0a 0d 0a 54 63 n integers....Tc
0de0: 6c 20 39 20 61 6c 6c 6f 77 73 20 74 68 65 20 75 l 9 allows the u
0df0: 73 65 20 6f 66 20 74 68 65 20 60 5f 60 20 75 6e se of the `_` un
0e00: 64 65 72 73 63 6f 72 65 20 63 68 61 72 61 63 74 derscore charact
0e10: 65 72 20 61 73 20 61 20 73 65 70 61 72 61 74 6f er as a separato
0e20: 72 20 69 6e 0d 0a 6e 75 6d 65 72 69 63 20 73 74 r in..numeric st
0e30: 72 69 6e 67 73 2c 20 65 2e 67 2e 20 60 31 5f 30 rings, e.g. `1_0
0e40: 30 30 5f 30 30 30 60 2c 20 60 31 5f 30 2e 30 5f 00_000`, `1_0.0_
0e50: 31 60 2e 20 49 74 20 69 73 20 69 6d 70 6f 72 74 1`. It is import
0e60: 61 6e 74 20 74 6f 20 6e 6f 74 65 0d 0a 74 68 61 ant to note..tha
0e70: 74 20 74 68 69 73 20 61 70 70 6c 69 65 73 20 6e t this applies n
0e80: 6f 74 20 6a 75 73 74 20 74 6f 20 6c 69 74 65 72 ot just to liter
0e90: 61 6c 73 20 69 6e 20 73 6f 75 72 63 65 20 63 6f als in source co
0ea0: 64 65 20 61 73 20 69 6e 20 73 6f 6d 65 20 6f 74 de as in some ot
0eb0: 68 65 72 0d 0a 6c 61 6e 67 75 61 67 65 73 20 62 her..languages b
0ec0: 75 74 20 72 75 6e 2d 74 69 6d 65 20 76 61 6c 75 ut run-time valu
0ed0: 65 73 20 61 73 20 77 65 6c 6c 2e 20 46 6f 72 20 es as well. For
0ee0: 65 78 61 6d 70 6c 65 2c 20 69 66 20 74 68 65 20 example, if the
0ef0: 60 73 74 72 69 6e 67 20 69 73 0d 0a 69 6e 74 65 `string is..inte
0f00: 67 65 72 60 20 63 6f 6d 6d 61 6e 64 20 69 73 20 ger` command is
0f10: 75 73 65 64 20 74 6f 20 76 61 6c 69 64 61 74 65 used to validate
0f20: 20 75 73 65 72 20 69 6e 70 75 74 20 61 73 20 69 user input as i
0f30: 6e 74 65 67 65 72 73 2c 20 69 74 20 77 69 6c 6c ntegers, it will
0f40: 0d 0a 61 6c 6c 6f 77 20 75 6e 64 65 72 73 63 6f ..allow undersco
0f50: 72 65 73 20 74 6f 20 62 65 20 65 6e 74 65 72 65 res to be entere
0f60: 64 2e 20 49 66 20 74 68 69 73 20 69 73 20 6e 6f d. If this is no
0f70: 74 20 64 65 73 69 72 65 64 2c 20 73 75 63 68 20 t desired, such
0f80: 76 61 6c 69 64 61 74 69 6f 6e 0d 0a 6e 65 65 64 validation..need
0f90: 73 20 74 6f 20 62 65 20 63 68 61 6e 67 65 64 20 s to be changed
0fa0: 74 6f 20 75 73 65 20 60 73 63 61 6e 60 20 6f 72 to use `scan` or
0fb0: 20 72 65 67 65 78 70 73 2e 0d 0a 0d 0a 53 65 65 regexps.....See
0fc0: 20 5b 54 49 50 20 35 35 31 5d 28 68 74 74 70 73 [TIP 551](https
0fd0: 3a 2f 2f 63 6f 72 65 2e 74 63 6c 2d 6c 61 6e 67 ://core.tcl-lang
0fe0: 2e 6f 72 67 2f 74 69 70 73 2f 64 6f 63 2f 74 72 .org/tips/doc/tr
0ff0: 75 6e 6b 2f 74 69 70 2f 35 35 31 2e 6d 64 29 2e unk/tip/551.md).
1000: 0d 0a 0d 0a 23 23 20 43 68 61 6e 67 65 73 20 69 ....## Changes i
1010: 6e 20 69 6e 74 65 67 65 72 20 63 6c 61 73 73 69 n integer classi
1020: 66 69 63 61 74 69 6f 6e 20 61 6e 64 20 68 61 6e fication and han
1030: 64 6c 69 6e 67 0d 0a 0d 0a 54 68 65 20 63 6f 6d dling....The com
1040: 6d 61 6e 64 20 60 73 74 72 69 6e 67 20 69 73 20 mand `string is
1050: 69 6e 74 65 67 65 72 60 20 6e 6f 77 20 61 63 63 integer` now acc
1060: 65 70 74 73 20 69 6e 74 65 67 65 72 73 20 6f 66 epts integers of
1070: 20 61 6e 79 20 73 69 7a 65 20 61 6e 64 20 69 73 any size and is
1080: 20 6e 6f 74 20 6c 69 6d 69 74 65 64 20 74 6f 20 not limited to
1090: 33 32 20 62 69 74 20 76 61 6c 75 65 73 2e 20 41 32 bit values. A
10a0: 6e 61 6c 6f 67 6f 75 73 6c 79 2c 20 74 68 65 20 nalogously, the
10b0: 60 69 6e 74 28 29 60 20 66 75 6e 63 74 69 6f 6e `int()` function
10c0: 20 77 69 6c 6c 20 6e 6f 20 6c 6f 6e 67 65 72 20 will no longer
10d0: 74 72 75 6e 63 61 74 65 20 69 6e 74 65 67 65 72 truncate integer
10e0: 20 76 61 6c 75 65 73 20 74 6f 20 61 20 33 32 2d values to a 32-
10f0: 62 69 74 20 72 61 6e 67 65 2e 20 54 68 65 20 66 bit range. The f
1100: 6f 6c 6c 6f 77 69 6e 67 20 69 6c 6c 75 73 74 72 ollowing illustr
1110: 61 74 65 73 20 74 68 65 20 64 69 66 66 65 72 65 ates the differe
1120: 6e 63 65 2e 0d 0a 0d 0a 49 6e 20 54 63 6c 20 38 nce.....In Tcl 8
1130: 2c 0d 0a 0d 0a 60 60 60 0d 0a 25 20 73 74 72 69 ,....```..% stri
1140: 6e 67 20 69 73 20 69 6e 74 65 67 65 72 20 30 78 ng is integer 0x
1150: 31 30 30 30 30 30 30 30 31 0d 0a 30 0d 0a 25 20 100000001..0..%
1160: 65 78 70 72 20 7b 69 6e 74 28 30 78 31 30 30 30 expr {int(0x1000
1170: 30 30 30 30 31 29 7d 0d 0a 31 0d 0a 60 60 60 0d 00001)}..1..```.
1180: 0a 0d 0a 49 6e 20 54 63 6c 20 39 2c 0d 0a 0d 0a ...In Tcl 9,....
1190: 60 60 60 0d 0a 25 20 73 74 72 69 6e 67 20 69 73 ```..% string is
11a0: 20 69 6e 74 65 67 65 72 20 30 78 31 30 30 30 30 integer 0x10000
11b0: 30 30 30 31 0d 0a 31 0d 0a 25 20 65 78 70 72 20 0001..1..% expr
11c0: 7b 69 6e 74 28 30 78 31 30 30 30 30 30 30 30 31 {int(0x100000001
11d0: 29 7d 0d 0a 34 32 39 34 39 36 37 32 39 37 0d 0a )}..4294967297..
11e0: 60 60 60 0d 0a 0d 0a 54 68 75 73 20 60 73 74 72 ```....Thus `str
11f0: 69 6e 67 20 69 73 20 69 6e 74 65 67 65 72 60 20 ing is integer`
1200: 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20 75 73 should not be us
1210: 65 64 20 66 6f 72 20 72 61 6e 67 65 20 76 61 6c ed for range val
1220: 69 64 61 74 69 6f 6e 3b 20 75 73 65 20 65 78 70 idation; use exp
1230: 6c 69 63 69 74 20 72 61 6e 67 65 20 63 68 65 63 licit range chec
1240: 6b 73 2e 20 4c 69 6b 65 77 69 73 65 2c 20 60 69 ks. Likewise, `i
1250: 6e 74 28 29 60 20 63 61 6e 6e 6f 74 20 62 65 20 nt()` cannot be
1260: 75 73 65 64 20 66 6f 72 20 74 72 75 6e 63 61 74 used for truncat
1270: 69 6f 6e 3b 20 75 73 65 20 65 78 70 6c 69 63 69 ion; use explici
1280: 74 20 6d 61 73 6b 69 6e 67 20 6f 66 20 68 69 67 t masking of hig
1290: 68 20 6f 72 64 65 72 20 62 69 74 73 2e 0d 0a 0d h order bits....
12a0: 0a 46 75 72 74 68 65 72 2c 20 74 68 65 20 63 6f .Further, the co
12b0: 6d 6d 61 6e 64 73 20 60 73 74 72 69 6e 67 20 69 mmands `string i
12c0: 73 20 65 6e 74 69 65 72 60 20 61 6e 64 20 60 73 s entier` and `s
12d0: 74 72 69 6e 67 20 69 73 20 77 69 64 65 60 20 61 tring is wide` a
12e0: 6e 64 20 66 75 6e 63 74 69 6f 6e 73 20 60 65 6e nd functions `en
12f0: 74 69 65 72 28 29 60 20 61 6e 64 20 60 77 69 64 tier()` and `wid
1300: 65 28 29 60 20 61 72 65 20 64 65 70 72 65 63 61 e()` are depreca
1310: 74 65 64 2e 20 41 67 61 69 6e 2c 20 75 73 65 20 ted. Again, use
1320: 65 78 70 6c 69 63 69 74 20 72 61 6e 67 65 20 63 explicit range c
1330: 68 65 63 6b 73 20 61 6e 64 20 6d 61 73 6b 69 6e hecks and maskin
1340: 67 20 69 6e 73 74 65 61 64 2e 0d 0a 0d 0a 53 65 g instead.....Se
1350: 65 20 5b 54 49 50 20 35 31 34 5d 28 68 74 74 70 e [TIP 514](http
1360: 73 3a 2f 2f 63 6f 72 65 2e 74 63 6c 2d 6c 61 6e s://core.tcl-lan
1370: 67 2e 6f 72 67 2f 74 69 70 73 2f 64 6f 63 2f 74 g.org/tips/doc/t
1380: 72 75 6e 6b 2f 74 69 70 2f 35 31 34 2e 6d 64 29 runk/tip/514.md)
1390: 2e 0d 0a 0d 0a 23 23 20 43 68 61 6e 67 65 20 69 .....## Change i
13a0: 6e 20 76 61 72 69 61 62 6c 65 20 6e 61 6d 65 20 n variable name
13b0: 72 65 73 6f 6c 75 74 69 6f 6e 0d 0a 0d 0a 49 6e resolution....In
13c0: 20 54 63 6c 20 38 20 76 61 72 69 61 62 6c 65 20 Tcl 8 variable
13d0: 6e 61 6d 65 73 20 74 68 61 74 20 61 72 65 20 6e names that are n
13e0: 6f 74 20 61 62 73 6f 6c 75 74 65 2c 20 61 72 65 ot absolute, are
13f0: 20 72 65 73 6f 6c 76 65 64 20 62 79 20 6c 6f 6f resolved by loo
1400: 6b 69 6e 67 20 66 69 72 73 74 20 69 6e 20 74 68 king first in th
1410: 65 20 63 75 72 72 65 6e 74 20 6e 61 6d 65 73 70 e current namesp
1420: 61 63 65 2c 20 61 6e 64 20 74 68 65 6e 20 69 6e ace, and then in
1430: 20 74 68 65 20 67 6c 6f 62 61 6c 20 6e 61 6d 65 the global name
1440: 73 70 61 63 65 2e 20 49 6e 20 54 63 6c 20 39 20 space. In Tcl 9
1450: 73 75 63 68 20 76 61 72 69 61 62 6c 65 73 20 61 such variables a
1460: 72 65 20 61 6c 77 61 79 73 20 69 6e 74 65 72 70 re always interp
1470: 72 65 74 65 64 20 61 73 20 72 65 6c 61 74 69 76 reted as relativ
1480: 65 20 74 6f 20 74 68 65 20 63 75 72 72 65 6e 74 e to the current
1490: 20 6e 61 6d 65 73 70 61 63 65 2e 0d 0a 0d 0a 54 namespace.....T
14a0: 68 69 73 20 61 76 6f 69 64 73 20 74 68 65 20 70 his avoids the p
14b0: 72 6f 62 6c 65 6d 20 74 68 61 74 20 73 65 74 74 roblem that sett
14c0: 69 6e 67 20 61 20 76 61 72 69 61 62 6c 65 20 69 ing a variable i
14d0: 6e 73 69 64 65 20 61 20 6e 61 6d 65 73 70 61 63 nside a namespac
14e0: 65 20 73 63 6f 70 65 20 77 69 6c 6c 20 6f 76 65 e scope will ove
14f0: 72 77 72 69 74 65 20 61 20 67 6c 6f 62 61 6c 20 rwrite a global
1500: 76 61 72 69 61 62 6c 65 2c 20 69 66 20 74 68 61 variable, if tha
1510: 74 20 67 6c 6f 62 61 6c 20 76 61 72 69 61 62 6c t global variabl
1520: 65 20 65 78 69 73 74 73 20 61 6e 64 20 74 68 65 e exists and the
1530: 20 76 61 72 69 61 62 6c 65 20 64 6f 65 73 20 6e variable does n
1540: 6f 74 20 65 78 69 73 74 20 72 65 6c 61 74 69 76 ot exist relativ
1550: 65 20 74 6f 20 74 68 65 20 6e 61 6d 65 73 70 61 e to the namespa
1560: 63 65 2e 20 42 75 74 20 69 74 20 61 6c 73 6f 20 ce. But it also
1570: 68 61 73 20 73 6f 6d 65 20 63 6f 6e 73 65 71 75 has some consequ
1580: 65 6e 63 65 73 20 74 68 61 74 20 6d 61 79 20 6e ences that may n
1590: 6f 74 20 69 6d 6d 65 64 69 61 74 65 6c 79 20 62 ot immediately b
15a0: 65 20 6f 62 76 69 6f 75 73 3a 0d 0a 0d 0a 2a 20 e obvious:....*
15b0: 41 63 63 65 73 73 20 74 6f 20 77 65 6c 6c 2d 6b Access to well-k
15c0: 6e 6f 77 6e 20 76 61 72 69 61 62 6c 65 73 20 73 nown variables s
15d0: 75 63 68 20 61 73 20 65 6e 76 20 61 6e 64 20 74 uch as env and t
15e0: 63 6c 5f 70 6c 61 74 66 6f 72 6d 20 69 6e 73 69 cl_platform insi
15f0: 64 65 20 61 20 6e 61 6d 65 73 70 61 63 65 20 65 de a namespace e
1600: 76 61 6c 20 62 6c 6f 63 6b 20 77 69 6c 6c 20 6e val block will n
1610: 65 65 64 20 74 6f 20 65 69 74 68 65 72 20 66 75 eed to either fu
1620: 6c 6c 79 20 71 75 61 6c 69 66 69 65 64 20 6f 72 lly qualified or
1630: 20 74 68 65 20 76 61 72 69 61 62 6c 65 20 6d 75 the variable mu
1640: 73 74 20 62 65 20 62 72 6f 75 67 68 74 20 69 6e st be brought in
1650: 74 6f 20 73 63 6f 70 65 20 75 73 69 6e 67 20 60 to scope using `
1660: 6e 61 6d 65 73 70 61 63 65 20 75 70 76 61 72 60 namespace upvar`
1670: 20 63 6f 6d 6d 61 6e 64 20 28 60 6e 61 6d 65 73 command (`names
1680: 70 61 63 65 20 75 70 76 61 72 20 3a 3a 20 65 6e pace upvar :: en
1690: 76 20 65 6e 76 60 29 2e 0d 0a 2a 20 49 6e 73 69 v env`)...* Insi
16a0: 64 65 20 70 72 6f 63 73 20 69 6e 20 61 20 6e 61 de procs in a na
16b0: 6d 65 73 70 61 63 65 20 6e 73 2c 20 69 74 20 75 mespace ns, it u
16c0: 73 65 64 20 74 6f 20 62 65 20 70 6f 73 73 69 62 sed to be possib
16d0: 6c 65 20 74 6f 20 61 63 63 65 73 73 20 6e 61 6d le to access nam
16e0: 65 73 70 61 63 65 20 76 61 72 69 61 62 6c 65 73 espace variables
16f0: 20 77 69 74 68 69 6e 20 61 20 67 6c 6f 62 61 6c within a global
1700: 20 6e 61 6d 65 73 70 61 63 65 20 60 6e 73 60 20 namespace `ns`
1710: 62 79 20 72 65 66 65 72 72 69 6e 67 20 74 6f 20 by referring to
1720: 74 68 65 6d 20 61 73 20 6e 73 3a 3a 76 61 72 2e them as ns::var.
1730: 20 54 68 61 74 20 6e 6f 20 6c 6f 6e 67 65 72 20 That no longer
1740: 77 6f 72 6b 73 2e 20 41 67 61 69 6e 2c 20 74 68 works. Again, th
1750: 65 20 73 6f 6c 75 74 69 6f 6e 20 69 73 20 74 6f e solution is to
1760: 20 65 69 74 68 65 72 20 66 75 6c 6c 79 20 71 75 either fully qu
1770: 61 6c 69 66 79 20 74 68 65 20 76 61 72 69 61 62 alify the variab
1780: 6c 65 2c 20 6f 72 20 62 72 69 6e 67 20 69 74 20 le, or bring it
1790: 69 6e 74 6f 20 73 63 6f 70 65 2e 20 49 6e 20 61 into scope. In a
17a0: 64 64 69 74 69 6f 6e 20 74 6f 20 74 68 65 20 6e ddition to the n
17b0: 61 6d 65 73 70 61 63 65 20 75 70 76 61 72 20 63 amespace upvar c
17c0: 6f 6d 6d 61 6e 64 2c 20 69 6e 20 74 68 69 73 20 ommand, in this
17d0: 63 61 73 65 20 74 68 61 74 20 63 61 6e 20 61 6c case that can al
17e0: 73 6f 20 62 65 20 64 6f 6e 65 20 75 73 69 6e 67 so be done using
17f0: 20 74 68 65 20 67 6c 6f 62 61 6c 20 63 6f 6d 6d the global comm
1800: 61 6e 64 20 28 60 67 6c 6f 62 61 6c 20 6e 73 3a and (`global ns:
1810: 3a 76 61 72 60 29 2c 20 61 73 20 77 65 6c 6c 20 :var`), as well
1820: 61 73 20 74 68 65 20 76 61 72 69 61 62 6c 65 20 as the variable
1830: 63 6f 6d 6d 61 6e 64 20 28 60 76 61 72 69 61 62 command (`variab
1840: 6c 65 20 76 61 72 60 2c 20 6f 72 20 60 76 61 72 le var`, or `var
1850: 69 61 62 6c 65 20 3a 3a 6e 73 3a 3a 76 61 72 60 iable ::ns::var`
1860: 29 2e 20 54 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 ). The following
1870: 20 65 67 72 65 70 20 6d 61 79 20 62 65 20 75 73 egrep may be us
1880: 65 66 75 6c 20 74 6f 20 64 65 74 65 63 74 20 73 eful to detect s
1890: 75 63 68 20 63 61 73 65 73 3a 0d 0a 60 60 60 0d uch cases:..```.
18a0: 0a 65 67 72 65 70 20 27 28 5c 53 2b 5c 73 2b 5c .egrep '(\S+\s+\
18b0: 24 7c 28 73 65 74 7c 75 6e 73 65 74 7c 61 70 70 $|(set|unset|app
18c0: 65 6e 64 7c 6c 73 65 74 7c 6c 61 70 70 65 6e 64 end|lset|lappend
18d0: 7c 64 69 63 74 5c 73 2b 28 73 65 74 7c 69 6e 63 |dict\s+(set|inc
18e0: 72 7c 61 70 70 65 6e 64 7c 6c 61 70 70 65 6e 64 r|append|lappend
18f0: 7c 77 69 74 68 7c 75 70 64 61 74 65 7c 75 6e 73 |with|update|uns
1900: 65 74 29 7c 75 70 76 61 72 7c 6e 61 6d 65 73 70 et)|upvar|namesp
1910: 61 63 65 20 76 61 72 7c 70 61 72 72 61 79 7c 69 ace var|parray|i
1920: 6e 66 6f 20 65 78 69 73 74 73 7c 67 65 74 73 5c nfo exists|gets\
1930: 73 2b 5c 53 2b 7c 61 72 72 61 79 5c 73 2b 5c 53 s+\S+|array\s+\S
1940: 2b 7c 76 77 61 69 74 29 5c 73 2b 29 5b 61 2d 7a +|vwait)\s+)[a-z
1950: 41 2d 5a 5d 2b 3a 3a 27 20 2a 2e 74 63 6c 0d 0a A-Z]+::' *.tcl..
1960: 60 60 60 0d 0a 4e 6f 74 20 61 20 63 6f 6d 70 6c ```..Not a compl
1970: 65 74 65 20 72 65 67 65 78 70 20 28 6f 6f 2c 20 ete regexp (oo,
1980: 65 78 70 72 2c 20 76 61 72 69 61 62 6c 65 20 61 expr, variable a
1990: 6e 64 20 6d 61 79 20 62 65 20 6f 74 68 65 72 20 nd may be other
19a0: 63 6f 6d 6d 61 6e 64 73 29 21 20 4e 6f 74 65 20 commands)! Note
19b0: 65 61 63 68 20 6f 63 63 75 72 72 65 6e 63 65 20 each occurrence
19c0: 68 61 73 20 74 6f 20 62 65 20 63 68 65 63 6b 65 has to be checke
19d0: 64 20 73 69 6e 63 65 20 69 74 20 6d 61 79 20 62 d since it may b
19e0: 65 20 6c 65 67 69 74 69 6d 61 74 65 20 72 65 66 e legitimate ref
19f0: 65 72 65 6e 63 65 20 72 65 6c 61 74 69 76 65 20 erence relative
1a00: 74 6f 20 74 68 65 20 63 75 72 72 65 6e 74 20 6e to the current n
1a10: 61 6d 65 73 70 61 63 65 2c 20 69 2e 65 2e 20 61 amespace, i.e. a
1a20: 20 63 68 69 6c 64 20 6e 61 6d 65 73 70 61 63 65 child namespace
1a30: 2c 20 28 74 6f 20 62 65 20 6c 65 66 74 20 61 6c , (to be left al
1a40: 6f 6e 65 29 20 6f 72 20 61 20 6e 6f 2d 6c 6f 6e one) or a no-lon
1a50: 67 65 72 2d 76 61 6c 69 64 20 72 65 66 65 72 65 ger-valid refere
1a60: 6e 63 65 20 72 65 6c 61 74 69 76 65 20 74 6f 20 nce relative to
1a70: 67 6c 6f 62 61 6c 20 6e 61 6d 65 73 70 61 63 65 global namespace
1a80: 20 28 77 68 69 63 68 20 6d 75 73 74 20 62 65 20 (which must be
1a90: 66 75 6c 6c 79 20 71 75 61 6c 69 66 69 65 64 29 fully qualified)
1aa0: 2e 20 53 74 72 6f 6e 67 6c 79 20 72 65 63 6f 6d . Strongly recom
1ab0: 6d 65 6e 64 65 64 20 74 68 69 73 20 63 68 65 63 mended this chec
1ac0: 6b 20 62 65 20 64 6f 6e 65 2e 20 74 63 6c 70 72 k be done. tclpr
1ad0: 6f 64 65 62 75 67 20 68 61 64 20 6f 76 65 72 20 odebug had over
1ae0: 35 30 30 20 73 75 63 68 20 72 65 66 65 72 65 6e 500 such referen
1af0: 63 65 73 20 28 70 65 72 66 65 63 74 6c 79 20 6c ces (perfectly l
1b00: 65 67 69 74 69 6d 61 74 65 20 69 6e 20 54 63 6c egitimate in Tcl
1b10: 38 2c 20 6e 6f 74 20 62 75 67 73 29 20 6c 65 61 8, not bugs) lea
1b20: 64 69 6e 67 20 74 6f 20 65 72 72 6f 72 20 65 78 ding to error ex
1b30: 63 65 70 74 69 6f 6e 73 20 69 66 20 6c 75 63 6b ceptions if luck
1b40: 79 20 61 6e 64 20 74 6f 20 72 61 74 68 65 72 20 y and to rather
1b50: 6d 79 73 74 65 72 69 6f 75 73 20 70 68 61 73 65 mysterious phase
1b60: 20 6f 66 20 74 68 65 20 6d 6f 6f 6e 20 6d 69 73 of the moon mis
1b70: 62 65 68 61 76 69 6f 72 20 6f 74 68 65 72 77 69 behavior otherwi
1b80: 73 65 2e 0d 0a 0d 0a 51 20 2d 20 68 61 73 20 74 se.....Q - has t
1b90: 68 65 20 62 65 68 61 76 69 6f 72 20 6f 66 20 60 he behavior of `
1ba0: 67 6c 6f 62 61 6c 60 20 63 68 61 6e 67 65 64 20 global` changed
1bb0: 77 69 74 68 69 6e 20 6e 61 6d 65 73 70 61 63 65 within namespace
1bc0: 73 3f 0d 0a 0d 0a 54 68 65 20 62 65 68 61 76 69 s?....The behavi
1bd0: 6f 72 20 6f 66 20 74 68 65 20 60 67 6c 6f 62 61 or of the `globa
1be0: 6c 60 20 63 6f 6d 6d 61 6e 64 20 77 69 74 68 69 l` command withi
1bf0: 6e 20 6e 61 6d 65 73 70 61 63 65 73 20 68 61 73 n namespaces has
1c00: 20 6e 6f 74 20 63 68 61 6e 67 65 64 2e 20 54 68 not changed. Th
1c10: 65 20 63 6f 6d 6d 61 6e 64 20 68 61 73 20 6e 6f e command has no
1c20: 20 65 66 66 65 63 74 20 77 68 65 6e 20 75 73 65 effect when use
1c30: 64 20 6f 75 74 73 69 64 65 20 74 68 65 20 63 6f d outside the co
1c40: 6e 74 65 78 74 20 6f 66 20 61 20 70 72 6f 63 20 ntext of a proc
1c50: 6f 72 20 61 70 70 6c 79 20 62 6f 64 79 2e 20 55 or apply body. U
1c60: 73 69 6e 67 20 60 67 6c 6f 62 61 6c 60 20 69 6e sing `global` in
1c70: 73 69 64 65 20 61 20 6e 61 6d 65 73 70 61 63 65 side a namespace
1c80: 20 65 76 61 6c 20 62 6c 6f 63 6b 20 64 6f 65 73 eval block does
1c90: 20 6e 6f 74 68 69 6e 67 2e 20 56 61 72 69 61 62 nothing. Variab
1ca0: 6c 65 20 6e 61 6d 65 73 20 70 61 73 73 65 64 20 le names passed
1cb0: 74 6f 20 74 68 65 20 67 6c 6f 62 61 6c 20 63 6f to the global co
1cc0: 6d 6d 61 6e 64 20 61 72 65 20 73 74 69 6c 6c 20 mmand are still
1cd0: 72 65 73 6f 6c 76 65 64 20 72 65 6c 61 74 69 76 resolved relativ
1ce0: 65 20 74 6f 20 74 68 65 20 67 6c 6f 62 61 6c 20 e to the global
1cf0: 6e 61 6d 65 73 70 61 63 65 2c 20 61 73 20 74 68 namespace, as th
1d00: 65 79 20 68 61 76 65 20 61 6c 77 61 79 73 20 62 ey have always b
1d10: 65 65 6e 2e 20 53 6f 2c 20 75 73 69 6e 67 20 60 een. So, using `
1d20: 67 6c 6f 62 61 6c 20 6e 73 3a 3a 76 61 72 60 20 global ns::var`
1d30: 28 69 6e 73 69 64 65 20 61 20 70 72 6f 63 20 6f (inside a proc o
1d40: 72 20 61 70 70 6c 79 20 62 6f 64 79 29 20 77 69 r apply body) wi
1d50: 6c 6c 20 63 72 65 61 74 65 20 61 20 6c 6f 63 61 ll create a loca
1d60: 6c 20 76 61 72 69 61 62 6c 65 20 76 61 72 20 74 l variable var t
1d70: 68 61 74 20 69 73 20 6c 69 6e 6b 65 64 20 74 6f hat is linked to
1d80: 20 74 68 65 20 6e 61 6d 65 73 70 61 63 65 20 76 the namespace v
1d90: 61 72 69 61 62 6c 65 20 3a 3a 6e 73 3a 3a 76 61 ariable ::ns::va
1da0: 72 2e 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 20 32 r.....See [TIP 2
1db0: 37 38 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 72 65 78](https://core
1dc0: 2e 74 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 .tcl-lang.org/ti
1dd0: 70 73 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 ps/doc/trunk/tip
1de0: 2f 32 37 38 2e 6d 64 29 2e 0d 0a 0d 0a 23 23 20 /278.md).....##
1df0: 43 68 61 6e 67 65 73 20 69 6e 20 70 61 72 73 69 Changes in parsi
1e00: 6e 67 20 6f 66 20 76 61 72 69 61 62 6c 65 20 6e ng of variable n
1e10: 61 6d 65 73 0d 0a 0d 0a 57 68 65 6e 20 70 61 72 ames....When par
1e20: 73 69 6e 67 20 62 72 61 63 65 64 20 76 61 72 69 sing braced vari
1e30: 61 62 6c 65 20 72 65 66 65 72 65 6e 63 65 73 20 able references
1e40: 6f 66 20 74 68 65 20 66 6f 72 6d 20 60 24 7b 2e of the form `${.
1e50: 2e 7d 60 2c 20 69 6e 20 38 2e 36 20 74 68 65 20 .}`, in 8.6 the
1e60: 66 69 72 73 74 20 60 7d 60 20 61 6c 77 61 79 73 first `}` always
1e70: 20 74 65 72 6d 69 6e 61 74 65 64 20 74 68 65 20 terminated the
1e80: 76 61 72 69 61 62 6c 65 20 6e 61 6d 65 2e 20 49 variable name. I
1e90: 6e 20 39 2e 30 2c 20 61 6e 79 20 6e 65 73 74 65 n 9.0, any neste
1ea0: 64 20 60 7b 60 20 61 72 65 20 63 6f 75 6e 74 65 d `{` are counte
1eb0: 64 20 61 6e 64 20 74 68 65 20 76 61 72 69 61 62 d and the variab
1ec0: 6c 65 20 6e 61 6d 65 20 69 73 20 74 65 72 6d 69 le name is termi
1ed0: 6e 61 74 65 64 20 62 79 20 74 68 65 20 60 7d 60 nated by the `}`
1ee0: 20 6d 61 74 63 68 69 6e 67 20 74 68 65 20 6f 70 matching the op
1ef0: 65 6e 69 6e 67 20 60 7b 60 2e 0d 0a 41 20 73 69 ening `{`...A si
1f00: 6d 69 6c 61 72 20 63 68 61 6e 67 65 20 61 6c 73 milar change als
1f10: 6f 20 61 70 70 6c 69 65 73 20 74 6f 20 70 61 72 o applies to par
1f20: 73 69 6e 67 20 6f 66 20 61 72 72 61 79 20 65 6c sing of array el
1f30: 65 6d 65 6e 74 20 6e 61 6d 65 73 20 65 6e 63 6c ement names encl
1f40: 6f 73 65 64 20 69 6e 20 60 28 29 60 2e 0d 0a 0d osed in `()`....
1f50: 0a 53 65 65 20 5b 54 49 50 20 34 36 35 5d 28 68 .See [TIP 465](h
1f60: 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 74 63 6c 2d ttps://core.tcl-
1f70: 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 73 2f 64 6f lang.org/tips/do
1f80: 63 2f 74 72 75 6e 6b 2f 74 69 70 2f 34 36 35 2e c/trunk/tip/465.
1f90: 6d 64 29 2e 0d 0a 0d 0a 23 23 20 41 72 67 75 6d md).....## Argum
1fa0: 65 6e 74 73 20 74 6f 20 60 6c 6f 61 64 60 20 61 ents to `load` a
1fb0: 72 65 20 55 6e 69 63 6f 64 65 2d 61 77 61 72 65 re Unicode-aware
1fc0: 20 61 6e 64 20 63 61 73 65 20 73 65 6e 73 69 74 and case sensit
1fd0: 69 76 65 0d 0a 0d 0a 49 6e 20 54 63 6c 20 38 2c ive....In Tcl 8,
1fe0: 20 74 68 65 20 73 65 63 6f 6e 64 20 61 72 67 75 the second argu
1ff0: 6d 65 6e 74 20 74 6f 20 74 68 65 20 60 6c 6f 61 ment to the `loa
2000: 64 60 20 63 6f 6d 6d 61 6e 64 20 77 68 69 63 68 d` command which
2010: 20 73 70 65 63 69 66 69 65 73 0d 0a 74 68 65 20 specifies..the
2020: 69 6e 69 74 69 61 6c 69 7a 61 74 69 6f 6e 20 66 initialization f
2030: 75 6e 63 74 69 6f 6e 20 77 61 73 20 63 61 73 65 unction was case
2040: 2d 69 6e 73 65 6e 73 69 74 69 76 65 2e 20 54 68 -insensitive. Th
2050: 69 73 20 69 73 20 69 6e 63 6f 6e 73 69 73 74 65 is is inconsiste
2060: 6e 74 0d 0a 77 69 74 68 20 74 68 65 20 72 75 6c nt..with the rul
2070: 65 73 20 66 6f 72 20 70 61 63 6b 61 67 65 20 6e es for package n
2080: 61 6d 65 73 20 77 68 69 63 68 20 61 72 65 20 63 ames which are c
2090: 61 73 65 2d 73 65 6e 73 69 74 69 76 65 2e 20 49 ase-sensitive. I
20a0: 6e 20 54 63 6c 20 39 2c 0d 0a 69 6e 69 74 69 61 n Tcl 9,..initia
20b0: 6c 69 7a 61 74 69 6f 6e 20 66 75 6e 63 74 69 6f lization functio
20c0: 6e 20 6e 61 6d 65 73 20 61 72 65 20 6e 6f 77 20 n names are now
20d0: 63 61 73 65 20 73 65 6e 73 69 74 69 76 65 2e 20 case sensitive.
20e0: 46 6f 72 20 65 78 61 6d 70 6c 65 2c 0d 0a 69 66 For example,..if
20f0: 20 74 68 65 20 69 6e 69 74 69 61 6c 69 7a 61 74 the initializat
2100: 69 6f 6e 20 66 75 6e 63 74 69 6f 6e 20 77 61 73 ion function was
2110: 20 63 61 6c 6c 65 64 20 60 53 61 6d 70 6c 65 5f called `Sample_
2120: 49 6e 69 74 60 2c 20 65 69 74 68 65 72 20 6f 66 Init`, either of
2130: 20 74 68 65 0d 0a 66 6f 6c 6c 6f 77 69 6e 67 20 the..following
2140: 63 6f 6d 6d 61 6e 64 73 20 77 6f 75 6c 64 20 77 commands would w
2150: 6f 72 6b 20 69 6e 20 54 63 6c 20 38 0d 0a 0d 0a ork in Tcl 8....
2160: 60 60 60 0d 0a 6c 6f 61 64 20 73 61 6d 70 6c 65 ```..load sample
2170: 2e 64 6c 6c 20 73 61 6d 70 6c 65 0d 0a 6c 6f 61 .dll sample..loa
2180: 64 20 73 61 6d 70 6c 65 2e 64 6c 6c 20 53 61 6d d sample.dll Sam
2190: 70 6c 65 0d 0a 60 60 60 0d 0a 0d 0a 49 6e 20 54 ple..```....In T
21a0: 63 6c 20 39 2c 20 6f 6e 6c 79 20 74 68 65 20 6c cl 9, only the l
21b0: 61 74 74 65 72 20 77 6f 75 6c 64 20 62 65 20 73 atter would be s
21c0: 75 63 63 65 73 73 66 75 6c 2e 0d 0a 0d 0a 49 66 uccessful.....If
21d0: 20 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 20 77 compatibility w
21e0: 69 74 68 20 62 6f 74 68 20 54 63 6c 20 38 20 61 ith both Tcl 8 a
21f0: 6e 64 20 39 20 69 73 20 64 65 73 69 72 65 64 2c nd 9 is desired,
2200: 20 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 0d 0a the following..
2210: 69 64 69 6f 6d 20 6d 61 79 20 62 65 20 75 73 65 idiom may be use
2220: 64 0d 0a 0d 0a 60 60 60 0d 0a 6c 6f 61 64 20 73 d....```..load s
2230: 61 6d 70 6c 65 2e 64 6c 6c 20 5b 73 74 72 69 6e ample.dll [strin
2240: 67 20 74 6f 74 69 74 6c 65 20 73 61 6d 70 6c 65 g totitle sample
2250: 5d 0d 0a 60 60 60 0d 0a 0d 0a 4e 6f 74 65 20 74 ]..```....Note t
2260: 68 61 74 20 69 6e 73 74 61 6e 63 65 73 20 6f 66 hat instances of
2270: 20 74 68 65 20 60 6c 6f 61 64 60 20 63 6f 6d 6d the `load` comm
2280: 61 6e 64 20 74 68 61 74 20 64 6f 20 6e 6f 74 20 and that do not
2290: 68 61 76 65 20 74 68 65 20 73 65 63 6f 6e 64 0d have the second.
22a0: 0a 61 72 67 75 6d 65 6e 74 20 73 70 65 63 69 66 .argument specif
22b0: 69 65 64 20 6e 65 65 64 20 6e 6f 74 20 62 65 20 ied need not be
22c0: 63 68 61 6e 67 65 64 2e 0d 0a 0d 0a 49 6e 20 61 changed.....In a
22d0: 64 64 69 74 69 6f 6e 2c 20 54 63 6c 20 39 20 64 ddition, Tcl 9 d
22e0: 6f 65 73 20 6e 6f 74 20 72 65 73 74 72 69 63 74 oes not restrict
22f0: 20 74 68 65 20 6e 61 6d 65 73 20 74 6f 20 41 53 the names to AS
2300: 43 49 49 2e 20 49 6e 20 70 72 61 63 74 69 63 65 CII. In practice
2310: 0d 0a 74 68 69 73 20 73 68 6f 75 6c 64 20 6e 6f ..this should no
2320: 74 20 68 61 76 65 20 61 6e 79 20 63 6f 6d 70 61 t have any compa
2330: 74 69 62 69 6c 69 74 79 20 69 73 73 75 65 73 2e tibility issues.
2340: 0d 0a 0d 0a 49 6e 20 61 64 64 69 74 69 6f 6e 2c ....In addition,
2350: 20 6c 69 62 72 61 72 79 20 6e 61 6d 65 73 20 63 library names c
2360: 6f 6d 70 69 6c 65 64 20 77 69 74 68 20 54 43 4c ompiled with TCL
2370: 39 20 68 65 61 64 65 72 73 20 67 65 74 20 74 68 9 headers get th
2380: 65 20 70 72 65 66 69 78 20 22 74 63 6c 39 22 20 e prefix "tcl9"
2390: 69 6e 20 69 74 73 20 6e 61 6d 65 2e 0d 0a 54 68 in its name...Th
23a0: 65 20 61 69 6d 20 69 73 20 74 6f 20 68 61 76 65 e aim is to have
23b0: 20 61 20 76 65 72 73 69 6f 6e 20 66 6f 72 20 54 a version for T
23c0: 43 4c 38 2e 37 20 61 6e 64 20 54 43 4c 39 20 69 CL8.7 and TCL9 i
23d0: 6e 20 74 68 65 20 73 61 6d 65 20 66 6f 6c 64 65 n the same folde
23e0: 72 2e 0d 0a 0d 0a 54 68 65 20 6e 61 6d 65 73 20 r.....The names
23f0: 61 72 65 20 61 73 20 66 6f 6c 6c 6f 77 73 3a 0d are as follows:.
2400: 0a 0d 0a 20 20 20 2a 20 20 20 74 6b 38 37 2e 64 ... * tk87.d
2410: 6c 6c 20 2d 3e 20 74 63 6c 39 74 6b 38 37 2e 64 ll -> tcl9tk87.d
2420: 6c 6c 20 28 6f 6e 20 57 69 6e 64 6f 77 73 29 0d ll (on Windows).
2430: 0a 20 20 20 2a 20 20 20 6c 69 62 74 6b 38 2e 37 . * libtk8.7
2440: 2e 73 6f 20 2d 3e 20 6c 69 62 74 63 6c 39 74 6b .so -> libtcl9tk
2450: 38 2e 37 2e 73 6f 20 28 6f 6e 20 55 4e 49 58 29 8.7.so (on UNIX)
2460: 0d 0a 0d 0a 41 20 74 79 70 69 63 61 6c 20 6d 75 ....A typical mu
2470: 6c 74 69 2d 76 65 72 73 69 6f 6e 20 70 6b 67 49 lti-version pkgI
2480: 6e 64 65 78 2e 74 63 6c 20 66 69 6c 65 20 6d 61 ndex.tcl file ma
2490: 79 20 6c 6f 6f 6b 20 6c 69 6b 65 20 74 68 69 73 y look like this
24a0: 3a 0d 0a 0d 0a 60 60 60 0d 0a 69 66 20 7b 21 5b :....```..if {![
24b0: 70 61 63 6b 61 67 65 20 76 73 61 74 69 73 66 69 package vsatisfi
24c0: 65 73 20 5b 70 61 63 6b 61 67 65 20 70 72 6f 76 es [package prov
24d0: 69 64 65 20 54 63 6c 5d 20 38 2e 36 2d 5d 7d 20 ide Tcl] 8.6-]}
24e0: 7b 0d 0a 20 20 20 20 72 65 74 75 72 6e 0d 0a 7d {.. return..}
24f0: 0d 0a 69 66 20 7b 5b 70 61 63 6b 61 67 65 20 76 ..if {[package v
2500: 73 61 74 69 73 66 69 65 73 20 5b 70 61 63 6b 61 satisfies [packa
2510: 67 65 20 70 72 6f 76 69 64 65 20 54 63 6c 5d 20 ge provide Tcl]
2520: 39 2e 30 2d 5d 7d 20 7b 0d 0a 20 20 20 20 70 61 9.0-]} {.. pa
2530: 63 6b 61 67 65 20 69 66 6e 65 65 64 65 64 20 74 ckage ifneeded t
2540: 64 62 63 3a 3a 6f 64 62 63 20 31 2e 31 2e 36 20 dbc::odbc 1.1.6
2550: 5c 0d 0a 09 20 20 20 20 22 5b 6c 69 73 74 20 6c \... "[list l
2560: 6f 61 64 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 24 oad [file join $
2570: 64 69 72 20 74 63 6c 39 74 64 62 63 6f 64 62 63 dir tcl9tdbcodbc
2580: 31 31 36 2e 64 6c 6c 5d 20 5b 73 74 72 69 6e 67 116.dll] [string
2590: 20 74 6f 74 69 74 6c 65 20 74 64 62 63 6f 64 62 totitle tdbcodb
25a0: 63 5d 5d 22 0d 0a 7d 20 65 6c 73 65 20 7b 0d 0a c]]"..} else {..
25b0: 20 20 20 20 70 61 63 6b 61 67 65 20 69 66 6e 65 package ifne
25c0: 65 64 65 64 20 74 64 62 63 3a 3a 6f 64 62 63 20 eded tdbc::odbc
25d0: 31 2e 31 2e 36 20 5c 0d 0a 09 20 20 20 20 22 5b 1.1.6 \... "[
25e0: 6c 69 73 74 20 6c 6f 61 64 20 5b 66 69 6c 65 20 list load [file
25f0: 6a 6f 69 6e 20 24 64 69 72 20 74 64 62 63 6f 64 join $dir tdbcod
2600: 62 63 31 31 36 2e 64 6c 6c 5d 20 5b 73 74 72 69 bc116.dll] [stri
2610: 6e 67 20 74 6f 74 69 74 6c 65 20 74 64 62 63 6f ng totitle tdbco
2620: 64 62 63 5d 5d 22 0d 0a 7d 0d 0a 60 60 60 0d 0a dbc]]"..}..```..
2630: 0d 0a 53 65 65 20 5b 54 49 50 20 35 39 35 5d 28 ..See [TIP 595](
2640: 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 74 63 6c https://core.tcl
2650: 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 73 2f 64 -lang.org/tips/d
2660: 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f 35 39 35 oc/trunk/tip/595
2670: 2e 6d 64 29 2e 0d 0a 0d 0a 23 23 20 57 72 69 74 .md).....## Writ
2680: 69 6e 67 20 76 65 72 73 69 6f 6e 20 61 6e 64 20 ing version and
2690: 62 75 69 6c 64 2d 69 6e 64 65 70 65 6e 64 65 6e build-independen
26a0: 74 20 70 6b 67 49 6e 64 65 78 2e 74 63 6c 20 66 t pkgIndex.tcl f
26b0: 69 6c 65 73 0d 0a 0d 0a 57 68 65 6e 20 77 72 69 iles....When wri
26c0: 74 69 6e 67 20 60 70 6b 67 49 6e 64 65 78 2e 74 ting `pkgIndex.t
26d0: 63 6c 60 20 66 69 6c 65 73 20 74 68 61 74 20 61 cl` files that a
26e0: 72 65 20 63 6f 6d 70 61 74 69 62 6c 65 20 77 69 re compatible wi
26f0: 74 68 20 62 6f 74 68 0d 0a 54 63 6c 20 38 20 61 th both..Tcl 8 a
2700: 6e 64 20 54 63 6c 20 39 20 61 73 20 77 65 6c 6c nd Tcl 9 as well
2710: 20 61 73 20 74 68 65 20 61 75 74 6f 63 6f 6e 66 as the autoconf
2720: 20 61 6e 64 20 6e 6d 61 6b 65 20 62 75 69 6c 64 and nmake build
2730: 20 73 79 73 74 65 6d 73 2c 20 74 68 65 0d 0a 66 systems, the..f
2740: 6f 6c 6c 6f 77 69 6e 67 20 64 69 66 66 65 72 65 ollowing differe
2750: 6e 63 65 73 20 6d 75 73 74 20 62 65 20 61 63 63 nces must be acc
2760: 6f 75 6e 74 65 64 20 66 6f 72 3a 0d 0a 0d 0a 2a ounted for:....*
2770: 20 49 72 72 65 73 70 65 63 74 69 76 65 20 6f 66 Irrespective of
2780: 20 74 68 65 20 62 75 69 6c 64 20 73 79 73 74 65 the build syste
2790: 6d 2c 20 54 63 6c 20 39 20 65 78 74 65 6e 73 69 m, Tcl 9 extensi
27a0: 6f 6e 20 62 69 6e 61 72 69 65 73 20 61 72 65 20 on binaries are
27b0: 6e 61 6d 65 64 20 64 69 66 66 65 72 65 6e 74 6c named differentl
27c0: 79 0d 0a 28 70 72 65 66 69 78 65 64 20 77 69 74 y..(prefixed wit
27d0: 68 20 60 74 63 6c 39 60 29 20 66 72 6f 6d 20 54 h `tcl9`) from T
27e0: 63 6c 20 38 0d 0a 0d 0a 2a 20 54 68 65 20 69 6e cl 8....* The in
27f0: 69 74 69 61 6c 69 7a 61 74 69 6f 6e 20 66 75 6e itialization fun
2800: 63 74 69 6f 6e 20 6e 61 6d 65 20 69 6e 20 54 63 ction name in Tc
2810: 6c 20 39 20 69 73 20 63 61 73 65 20 73 65 6e 73 l 9 is case sens
2820: 69 74 69 76 65 20 61 73 20 6e 6f 74 65 64 20 70 itive as noted p
2830: 72 65 76 69 6f 75 73 6c 79 2e 0d 0a 0d 0a 2a 20 reviously.....*
2840: 49 6e 20 54 63 6c 20 38 2c 20 65 78 74 65 6e 73 In Tcl 8, extens
2850: 69 6f 6e 20 62 69 6e 61 72 69 65 73 20 62 75 69 ion binaries bui
2860: 6c 74 20 77 69 74 68 20 74 68 65 20 6e 6d 61 6b lt with the nmak
2870: 65 20 73 79 73 74 65 6d 20 68 61 76 65 20 61 20 e system have a
2880: 73 75 66 66 69 78 20 61 74 74 61 63 68 65 64 2e suffix attached.
2890: 0d 0a 46 6f 72 20 65 78 61 6d 70 6c 65 2c 20 74 ..For example, t
28a0: 68 72 65 61 64 65 64 20 62 75 69 6c 64 73 20 68 hreaded builds h
28b0: 61 76 65 20 61 20 60 74 60 20 73 75 66 66 69 78 ave a `t` suffix
28c0: 20 61 74 74 61 63 68 65 64 20 77 68 69 6c 65 20 attached while
28d0: 6e 6f 6e 2d 74 68 72 65 61 64 65 64 20 62 75 69 non-threaded bui
28e0: 6c 64 73 0d 0a 64 6f 20 6e 6f 74 2e 20 54 68 65 lds..do not. The
28f0: 20 61 75 74 6f 74 6f 6f 6c 73 20 62 61 73 65 64 autotools based
2900: 20 62 75 69 6c 64 20 73 79 73 74 65 6d 20 64 6f build system do
2910: 65 73 20 6e 6f 74 20 64 69 73 74 69 6e 67 75 69 es not distingui
2920: 73 68 20 69 6e 20 74 68 69 73 20 6d 61 6e 6e 65 sh in this manne
2930: 72 2e 20 54 68 69 73 0d 0a 69 6e 63 6f 6e 73 69 r. This..inconsi
2940: 73 74 65 6e 63 79 20 69 73 20 6e 6f 74 20 70 72 stency is not pr
2950: 65 73 65 6e 74 20 69 6e 20 54 63 6c 20 39 20 62 esent in Tcl 9 b
2960: 75 74 20 6e 65 65 64 73 20 74 6f 20 62 65 20 61 ut needs to be a
2970: 63 63 6f 75 6e 74 65 64 20 66 6f 72 20 69 66 20 ccounted for if
2980: 74 68 65 20 70 61 63 6b 61 67 65 0d 0a 73 75 70 the package..sup
2990: 70 6f 72 74 73 20 62 6f 74 68 20 54 63 6c 20 76 ports both Tcl v
29a0: 65 72 73 69 6f 6e 73 20 61 6e 64 20 62 75 69 6c ersions and buil
29b0: 64 20 73 79 73 74 65 6d 73 2e 0d 0a 0d 0a 54 68 d systems.....Th
29c0: 65 20 73 69 6d 70 6c 65 73 74 20 77 61 79 20 74 e simplest way t
29d0: 6f 20 61 63 68 69 65 76 65 20 74 68 65 20 61 62 o achieve the ab
29e0: 6f 76 65 20 76 69 61 20 74 68 65 20 54 45 41 20 ove via the TEA
29f0: 62 75 69 6c 64 20 73 79 73 74 65 6d 20 69 73 20 build system is
2a00: 74 6f 20 77 72 69 74 65 20 61 0d 0a 60 70 6b 67 to write a..`pkg
2a10: 49 6e 64 65 78 2e 74 63 6c 2e 69 6e 60 20 74 65 Index.tcl.in` te
2a20: 6d 70 6c 61 74 65 20 66 6f 72 20 61 75 74 6f 63 mplate for autoc
2a30: 6f 6e 66 20 73 69 6d 69 6c 61 72 20 74 6f 20 74 onf similar to t
2a40: 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 3a 0d 0a 0d he following:...
2a50: 0a 60 60 60 0d 0a 70 61 63 6b 61 67 65 20 69 66 .```..package if
2a60: 6e 65 65 64 65 64 20 40 50 41 43 4b 41 47 45 5f needed @PACKAGE_
2a70: 4e 41 4d 45 40 20 40 50 41 43 4b 41 47 45 5f 56 NAME@ @PACKAGE_V
2a80: 45 52 53 49 4f 4e 40 20 5c 0d 0a 20 20 20 20 5b ERSION@ \.. [
2a90: 6c 69 73 74 20 61 70 70 6c 79 20 5b 6c 69 73 74 list apply [list
2aa0: 20 7b 64 69 72 7d 20 7b 0d 0a 20 20 20 20 20 20 {dir} {..
2ab0: 20 20 73 65 74 20 70 61 63 6b 61 67 65 49 6e 69 set packageIni
2ac0: 74 4e 61 6d 65 20 5b 73 74 72 69 6e 67 20 74 6f tName [string to
2ad0: 74 69 74 6c 65 20 40 50 41 43 4b 41 47 45 5f 4e title @PACKAGE_N
2ae0: 41 4d 45 40 5d 0d 0a 20 20 20 20 20 20 20 20 73 AME@].. s
2af0: 65 74 20 70 61 74 68 20 5b 66 69 6c 65 20 6a 6f et path [file jo
2b00: 69 6e 20 24 64 69 72 20 22 40 50 4b 47 5f 4c 49 in $dir "@PKG_LI
2b10: 42 5f 46 49 4c 45 40 22 5d 0d 0a 20 20 20 20 20 B_FILE@"]..
2b20: 20 20 20 75 70 6c 65 76 65 6c 20 23 30 20 5b 6c uplevel #0 [l
2b30: 69 73 74 20 6c 6f 61 64 20 24 70 61 74 68 20 24 ist load $path $
2b40: 70 61 63 6b 61 67 65 49 6e 69 74 4e 61 6d 65 5d packageInitName]
2b50: 0d 0a 20 20 20 20 7d 5d 20 24 64 69 72 5d 0d 0a .. }] $dir]..
2b60: 60 60 60 0d 0a 0d 0a 54 68 65 20 60 63 6f 6e 66 ```....The `conf
2b70: 69 67 75 72 65 2e 61 63 60 20 69 6e 20 74 68 65 igure.ac` in the
2b80: 20 61 75 74 6f 74 6f 6f 6c 73 20 62 75 69 6c 64 autotools build
2b90: 20 73 68 6f 75 6c 64 20 63 6f 6e 74 61 69 6e 20 should contain
2ba0: 74 68 65 20 6c 69 6e 65 0d 0a 0d 0a 60 60 60 0d the line....```.
2bb0: 0a 41 43 5f 43 4f 4e 46 49 47 5f 46 49 4c 45 53 .AC_CONFIG_FILES
2bc0: 28 5b 4d 61 6b 65 66 69 6c 65 20 70 6b 67 49 6e ([Makefile pkgIn
2bd0: 64 65 78 2e 74 63 6c 5d 29 0d 0a 60 60 60 0d 0a dex.tcl])..```..
2be0: 0d 0a 54 68 65 20 60 6d 61 6b 65 66 69 6c 65 2e ..The `makefile.
2bf0: 76 63 60 20 73 68 6f 75 6c 64 20 63 6f 6e 74 61 vc` should conta
2c00: 69 6e 20 74 68 65 20 6c 69 6e 65 0d 0a 0d 0a 60 in the line....`
2c10: 60 60 0d 0a 70 6b 67 69 6e 64 65 78 3a 20 64 65 ``..pkgindex: de
2c20: 66 61 75 6c 74 2d 70 6b 67 69 6e 64 65 78 2d 74 fault-pkgindex-t
2c30: 65 61 0d 0a 60 60 60 0d 0a 0d 0a 54 68 69 73 20 ea..```....This
2c40: 77 69 6c 6c 20 72 65 73 75 6c 74 20 69 6e 20 62 will result in b
2c50: 6f 74 68 20 62 75 69 6c 64 20 73 79 73 74 65 6d oth build system
2c60: 73 20 67 65 6e 65 72 61 74 69 6e 67 20 61 20 60 s generating a `
2c70: 70 6b 67 49 6e 64 65 78 2e 74 63 6c 60 0d 0a 74 pkgIndex.tcl`..t
2c80: 68 61 74 20 77 6f 72 6b 73 20 66 6f 72 20 54 63 hat works for Tc
2c90: 6c 20 38 20 61 73 20 77 65 6c 6c 20 61 73 20 54 l 8 as well as T
2ca0: 63 6c 20 39 2e 0d 0a 0d 0a 0d 0a 23 23 20 44 65 cl 9.......## De
2cb0: 66 61 75 6c 74 20 65 6e 63 6f 64 69 6e 67 20 66 fault encoding f
2cc0: 6f 72 20 73 63 72 69 70 74 73 20 69 73 20 55 54 or scripts is UT
2cd0: 46 2d 38 0d 0a 0d 0a 54 68 65 20 64 65 66 61 75 F-8....The defau
2ce0: 6c 74 20 65 6e 63 6f 64 69 6e 67 20 75 73 65 64 lt encoding used
2cf0: 20 77 68 65 6e 20 72 65 61 64 69 6e 67 20 73 63 when reading sc
2d00: 72 69 70 74 73 2c 20 65 69 74 68 65 72 20 77 69 ripts, either wi
2d10: 74 68 20 74 68 65 20 60 73 6f 75 72 63 65 60 0d th the `source`.
2d20: 0a 63 6f 6d 6d 61 6e 64 20 77 69 74 68 6f 75 74 .command without
2d30: 20 61 6e 20 65 78 70 6c 69 63 69 74 20 60 2d 65 an explicit `-e
2d40: 6e 63 6f 64 69 6e 67 60 20 6f 70 74 69 6f 6e 2c ncoding` option,
2d50: 20 6f 72 20 70 61 73 73 65 64 20 61 73 20 61 20 or passed as a
2d60: 63 6f 6d 6d 61 6e 64 0d 0a 6c 69 6e 65 20 61 72 command..line ar
2d70: 67 75 6d 65 6e 74 20 74 6f 20 60 74 63 6c 73 68 gument to `tclsh
2d80: 60 20 69 73 20 75 74 66 2d 38 20 69 6e 20 54 63 ` is utf-8 in Tc
2d90: 6c 20 39 20 69 6e 73 74 65 61 64 20 6f 66 20 74 l 9 instead of t
2da0: 68 65 20 73 79 73 74 65 6d 0d 0a 65 6e 63 6f 64 he system..encod
2db0: 69 6e 67 20 61 73 20 69 6e 20 54 63 6c 20 38 2e ing as in Tcl 8.
2dc0: 0d 0a 0d 0a 4e 6f 20 63 68 61 6e 67 65 73 20 61 ....No changes a
2dd0: 72 65 20 72 65 71 75 69 72 65 64 20 66 6f 72 20 re required for
2de0: 73 63 72 69 70 74 73 20 74 68 61 74 20 77 65 72 scripts that wer
2df0: 65 20 70 75 72 65 20 41 53 43 49 49 20 61 6e 64 e pure ASCII and
2e00: 20 75 73 65 64 0d 0a 74 68 65 20 60 5c 75 60 20 used..the `\u`
2e10: 6f 72 20 60 5c 55 60 20 65 73 63 61 70 65 73 20 or `\U` escapes
2e20: 66 6f 72 20 6e 6f 6e 2d 41 53 43 49 49 20 63 68 for non-ASCII ch
2e30: 61 72 61 63 74 65 72 73 2e 20 53 63 72 69 70 74 aracters. Script
2e40: 73 20 74 68 61 74 20 77 65 72 65 0d 0a 73 61 76 s that were..sav
2e50: 65 64 20 75 73 69 6e 67 20 61 20 28 6e 6f 6e 2d ed using a (non-
2e60: 75 74 66 38 29 20 73 79 73 74 65 6d 20 65 6e 63 utf8) system enc
2e70: 6f 64 69 6e 67 20 77 69 6c 6c 20 68 61 76 65 20 oding will have
2e80: 74 6f 20 62 65 20 6d 6f 64 69 66 69 65 64 0d 0a to be modified..
2e90: 6f 72 20 73 6f 75 72 63 65 64 20 75 73 69 6e 67 or sourced using
2ea0: 20 61 6e 20 65 78 70 6c 69 63 69 74 20 60 2d 65 an explicit `-e
2eb0: 6e 63 6f 64 69 6e 67 60 20 6f 70 74 69 6f 6e 2e ncoding` option.
2ec0: 0d 0a 0d 0a 49 6e 20 54 43 4c 38 2e 36 2c 20 69 ....In TCL8.6, i
2ed0: 74 20 69 73 20 61 6e 79 77 61 79 20 67 6f 6f 64 t is anyway good
2ee0: 20 70 72 61 63 74 69 63 65 20 74 6f 20 69 6e 63 practice to inc
2ef0: 6c 75 64 65 20 74 68 65 20 60 2d 65 6e 63 6f 64 lude the `-encod
2f00: 69 6e 67 60 20 70 61 72 61 6d 65 74 65 72 20 74 ing` parameter t
2f10: 6f 20 74 68 65 20 73 6f 75 72 63 65 20 63 6f 6d o the source com
2f20: 6d 61 6e 64 20 66 6f 72 20 70 6f 72 74 61 62 69 mand for portabi
2f30: 6c 69 74 79 2e 0d 0a 41 20 70 6b 67 49 6e 64 65 lity...A pkgInde
2f40: 78 2e 74 63 6c 20 66 69 6c 65 20 6d 61 79 20 6c x.tcl file may l
2f50: 6f 6f 6b 20 6c 69 6b 65 20 74 68 69 73 3a 0d 0a ook like this:..
2f60: 60 60 60 0d 0a 70 61 63 6b 61 67 65 20 69 66 6e ```..package ifn
2f70: 65 65 64 65 64 20 6d 79 70 61 63 6b 61 67 65 20 eeded mypackage
2f80: 31 2e 30 20 5b 6c 69 73 74 20 73 6f 75 72 63 65 1.0 [list source
2f90: 20 2d 65 6e 63 6f 64 69 6e 67 20 63 70 31 32 35 -encoding cp125
2fa0: 32 20 5b 66 69 6c 65 20 6a 6f 69 6e 20 24 64 69 2 [file join $di
2fb0: 72 20 6d 79 70 61 63 6b 61 67 65 2e 74 63 6c 5d r mypackage.tcl]
2fc0: 5d 0d 0a 60 60 60 0d 0a 54 68 69 73 20 77 69 6c ]..```..This wil
2fd0: 6c 20 73 74 69 6c 6c 20 77 6f 72 6b 20 69 6e 20 l still work in
2fe0: 39 2e 30 20 66 6f 72 20 61 6e 79 20 73 75 70 70 9.0 for any supp
2ff0: 6f 72 74 65 64 20 63 6f 64 65 70 61 67 65 2e 0d orted codepage..
3000: 0a 0d 0a 53 65 65 20 5b 54 49 50 20 35 38 37 5d ...See [TIP 587]
3010: 28 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 74 63 (https://core.tc
3020: 6c 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 73 2f l-lang.org/tips/
3030: 64 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f 35 38 doc/trunk/tip/58
3040: 37 2e 6d 64 29 2e 0d 0a 0d 0a 23 23 20 45 6e 63 7.md).....## Enc
3050: 6f 64 69 6e 67 20 70 72 6f 66 69 6c 65 20 2a 73 oding profile *s
3060: 74 72 69 63 74 2a 20 66 6f 72 20 73 63 72 69 70 trict* for scrip
3070: 74 73 0d 0a 0d 0a 54 68 65 20 73 74 72 69 63 74 ts....The strict
3080: 20 65 6e 63 6f 64 69 6e 67 20 70 72 6f 66 69 6c encoding profil
3090: 65 20 61 70 70 6c 69 65 73 20 74 6f 20 74 68 65 e applies to the
30a0: 20 73 6f 75 72 63 65 20 63 6f 6d 6d 61 6e 64 2e source command.
30b0: 0d 0a 54 68 65 20 73 6f 75 72 63 65 20 63 6f 6d ..The source com
30c0: 6d 61 6e 64 20 6d 61 79 20 74 68 72 6f 77 20 65 mand may throw e
30d0: 6e 63 6f 64 69 6e 67 20 65 72 72 6f 72 73 2e 0d ncoding errors..
30e0: 0a 0d 0a 53 63 72 69 70 74 73 20 77 69 74 68 20 ...Scripts with
30f0: 6e 6f 6e 20 41 53 43 49 49 20 63 68 61 72 61 63 non ASCII charac
3100: 74 65 72 73 2c 20 65 76 65 6e 20 69 6e 20 63 6f ters, even in co
3110: 6d 6d 65 6e 74 73 2c 20 6d 61 79 20 6e 6f 77 20 mments, may now
3120: 66 61 69 6c 20 69 66 20 74 68 65 20 65 6e 63 6f fail if the enco
3130: 64 69 6e 67 20 69 73 20 77 72 6f 6e 67 2e 0d 0a ding is wrong...
3140: 41 20 74 79 70 69 63 61 6c 20 65 78 61 6d 70 6c A typical exampl
3150: 65 20 69 73 20 61 20 63 6f 70 79 72 69 67 68 74 e is a copyright
3160: 20 67 6c 79 70 68 20 69 6e 20 61 20 6e 6f 6e 20 glyph in a non
3170: 55 54 46 2d 38 20 63 6f 64 65 70 61 67 65 20 22 UTF-8 codepage "
3180: c2 a9 22 20 73 63 72 69 70 74 20 66 69 6c 65 2e ©" script file.
3190: 0d 0a 0d 0a 49 6e 20 54 43 4c 38 2e 36 2c 20 74 ....In TCL8.6, t
31a0: 68 6f 73 65 20 65 72 72 6f 72 73 20 64 69 64 20 hose errors did
31b0: 6e 6f 74 20 61 72 69 73 65 2c 20 61 73 20 74 68 not arise, as th
31c0: 65 20 61 63 74 69 76 65 20 74 63 6c 38 20 70 72 e active tcl8 pr
31d0: 6f 66 69 6c 65 20 73 69 6c 65 6e 74 6c 79 20 63 ofile silently c
31e0: 68 61 6e 67 65 64 20 74 68 6f 73 65 20 63 68 61 hanged those cha
31f0: 72 61 63 74 65 72 73 20 74 6f 20 69 6e 6c 69 6e racters to inlin
3200: 65 20 69 73 6f 2d 38 38 35 39 2d 31 20 63 68 61 e iso-8859-1 cha
3210: 72 61 63 74 65 72 73 2e 0d 0a 49 66 20 69 74 20 racters...If it
3220: 77 61 73 20 72 65 61 6c 20 63 6f 64 65 20 28 6c was real code (l
3230: 69 6b 65 20 74 65 78 74 29 2c 20 74 68 65 20 73 ike text), the s
3240: 63 72 69 70 74 20 63 68 61 6e 67 65 64 20 69 6e cript changed in
3250: 20 66 75 6e 63 74 69 6f 6e 61 6c 69 74 79 2e 0d functionality..
3260: 0a 0d 0a 23 23 20 53 79 73 74 65 6d 20 65 6e 63 ...## System enc
3270: 6f 64 69 6e 67 20 6f 6e 20 57 69 6e 64 6f 77 73 oding on Windows
3280: 20 6d 61 79 20 63 68 61 6e 67 65 20 74 6f 20 55 may change to U
3290: 54 46 2d 38 0d 0a 0d 0a 54 68 65 20 57 69 6e 64 TF-8....The Wind
32a0: 6f 77 73 20 65 78 65 63 75 74 61 62 6c 65 20 4d ows executable M
32b0: 61 6e 69 66 65 73 74 20 6f 66 20 74 63 6c 73 68 anifest of tclsh
32c0: 2e 65 78 65 20 61 6e 64 20 77 69 73 68 2e 65 78 .exe and wish.ex
32d0: 65 20 77 65 72 65 20 63 68 61 6e 67 65 64 20 74 e were changed t
32e0: 6f 20 63 6c 61 69 6d 20 55 54 46 2d 38 20 63 68 o claim UTF-8 ch
32f0: 61 72 61 63 74 65 72 20 73 65 74 2e 0d 0a 4f 6e aracter set...On
3300: 20 6d 79 20 57 69 6e 64 6f 77 73 20 31 30 20 73 my Windows 10 s
3310: 79 73 74 65 6d 20 77 69 74 68 20 47 65 72 6d 61 ystem with Germa
3320: 6e 20 6c 6f 63 61 6c 65 2c 20 74 68 65 20 63 6f n locale, the co
3330: 6d 6d 61 6e 64 20 2a 65 6e 63 6f 64 69 6e 67 20 mmand *encoding
3340: 73 79 73 74 65 6d 2a 20 72 65 74 75 72 6e 73 20 system* returns
3350: 2a 75 74 66 2d 38 2a 20 77 69 74 68 20 54 43 4c *utf-8* with TCL
3360: 2f 54 6b 20 39 2e 30 20 61 6e 64 20 2a 63 70 31 /Tk 9.0 and *cp1
3370: 32 35 32 2a 20 77 69 74 68 20 54 43 4c 2f 54 6b 252* with TCL/Tk
3380: 20 38 2e 36 2e 0d 0a 54 68 69 73 20 69 73 20 64 8.6...This is d
3390: 75 65 20 74 6f 20 74 68 65 20 6d 61 6e 69 66 65 ue to the manife
33a0: 73 74 20 63 68 61 6e 67 65 2c 20 6e 6f 74 20 61 st change, not a
33b0: 6e 79 20 63 68 61 6e 67 65 20 77 69 74 68 69 6e ny change within
33c0: 20 54 43 4c 2f 54 6b 2e 0d 0a 0d 0a 44 75 65 20 TCL/Tk.....Due
33d0: 74 6f 20 74 68 61 74 2c 20 74 68 65 20 63 68 61 to that, the cha
33e0: 6e 67 65 20 74 6f 20 55 54 46 2d 38 20 65 6e 63 nge to UTF-8 enc
33f0: 6f 64 69 6e 67 20 6f 66 20 74 68 65 20 73 6f 75 oding of the sou
3400: 72 63 65 20 63 6f 6d 6d 61 6e 64 20 6d 61 79 20 rce command may
3410: 6e 6f 74 20 62 65 20 2a 72 65 76 65 72 74 65 64 not be *reverted
3420: 2a 20 62 79 3a 0d 0a 0d 0a 60 60 60 0d 0a 73 6f * by:....```..so
3430: 75 72 63 65 20 2d 65 6e 63 6f 64 69 6e 67 20 5b urce -encoding [
3440: 65 6e 63 6f 64 69 6e 67 20 73 79 73 74 65 6d 5d encoding system]
3450: 20 66 69 6c 65 2e 74 63 6c 0d 0a 60 60 60 0d 0a file.tcl..```..
3460: 0d 0a 46 6f 72 20 6d 65 2c 20 74 68 69 73 20 69 ..For me, this i
3470: 73 20 61 63 63 6f 72 64 69 6e 67 20 77 68 65 72 s according wher
3480: 65 20 57 69 6e 64 6f 77 73 20 69 73 20 6d 6f 76 e Windows is mov
3490: 69 6e 67 2e 0d 0a 49 66 20 49 20 63 72 65 61 74 ing...If I creat
34a0: 65 20 6e 6f 77 64 61 79 73 20 61 20 66 69 6c 65 e nowdays a file
34b0: 20 75 73 69 6e 67 20 74 68 65 20 57 69 6e 64 6f using the Windo
34c0: 77 73 20 65 64 69 74 6f 72 20 61 70 70 6c 69 63 ws editor applic
34d0: 61 74 69 6f 6e 2c 20 69 74 20 69 73 20 65 6e 63 ation, it is enc
34e0: 6f 64 65 64 20 69 6e 20 55 54 46 2d 38 2e 0d 0a oded in UTF-8...
34f0: 57 69 74 68 20 6f 6c 64 65 72 20 57 69 6e 64 6f With older Windo
3500: 77 73 20 76 65 72 73 69 6f 6e 73 2c 20 74 68 69 ws versions, thi
3510: 73 20 77 61 73 20 63 70 31 32 35 32 2e 0d 0a 0d s was cp1252....
3520: 0a 4f 6e 65 20 65 66 66 65 63 74 20 6f 66 20 74 .One effect of t
3530: 68 69 73 20 69 73 20 74 68 61 74 20 61 20 66 69 his is that a fi
3540: 6c 65 20 77 72 69 74 74 65 6e 20 62 79 20 61 20 le written by a
3550: 38 2e 78 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 8.x application
3560: 75 73 69 6e 67 0d 0a 74 68 65 20 64 65 66 61 75 using..the defau
3570: 6c 74 20 65 6e 63 6f 64 69 6e 67 20 77 69 6c 6c lt encoding will
3580: 20 6e 6f 74 20 62 65 20 72 65 61 64 61 62 6c 65 not be readable
3590: 20 62 79 20 61 20 39 2e 78 20 61 70 70 6c 69 63 by a 9.x applic
35a0: 61 74 69 6f 6e 20 75 6e 6c 65 73 73 0d 0a 74 68 ation unless..th
35b0: 65 20 63 68 61 6e 6e 65 6c 20 69 73 20 65 78 70 e channel is exp
35c0: 6c 69 63 69 74 6c 79 20 63 6f 6e 66 69 67 75 72 licitly configur
35d0: 65 64 20 74 6f 20 75 73 65 20 74 68 65 20 6f 72 ed to use the or
35e0: 69 67 69 6e 61 6c 20 65 6e 63 6f 64 69 6e 67 2e iginal encoding.
35f0: 0d 0a 55 6e 66 6f 72 74 75 6e 61 74 65 6c 79 2c ..Unfortunately,
3600: 20 74 68 65 72 65 20 69 73 20 6e 6f 20 77 61 79 there is no way
3610: 20 74 6f 20 6b 6e 6f 77 20 74 68 65 20 6f 72 69 to know the ori
3620: 67 69 6e 61 6c 20 64 65 66 61 75 6c 74 20 65 6e ginal default en
3630: 63 6f 64 69 6e 67 2e 0d 0a 41 20 2a 2a 67 75 65 coding...A **gue
3640: 73 73 2a 2a 20 6d 61 79 20 62 65 20 6d 61 64 65 ss** may be made
3650: 20 62 79 20 63 68 65 63 6b 69 6e 67 20 74 68 65 by checking the
3660: 20 57 69 6e 64 6f 77 73 20 72 65 67 69 73 74 72 Windows registr
3670: 79 3b 20 73 6f 6d 65 74 68 69 6e 67 0d 0a 61 6c y; something..al
3680: 6f 6e 67 20 74 68 65 20 6c 69 6e 65 73 20 6f 66 ong the lines of
3690: 20 28 65 72 72 6f 72 20 63 68 65 63 6b 69 6e 67 (error checking
36a0: 20 69 67 6e 6f 72 65 64 29 0d 0a 0d 0a 60 60 60 ignored)....```
36b0: 0d 0a 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 ..package requir
36c0: 65 20 72 65 67 69 73 74 72 79 0d 0a 73 65 74 20 e registry..set
36d0: 77 69 6e 43 6f 64 65 50 61 67 65 20 5b 72 65 67 winCodePage [reg
36e0: 69 73 74 72 79 20 67 65 74 20 7b 48 4b 45 59 5f istry get {HKEY_
36f0: 4c 4f 43 41 4c 5f 4d 41 43 48 49 4e 45 5c 53 59 LOCAL_MACHINE\SY
3700: 53 54 45 4d 5c 43 75 72 72 65 6e 74 43 6f 6e 74 STEM\CurrentCont
3710: 72 6f 6c 53 65 74 5c 43 6f 6e 74 72 6f 6c 5c 4e rolSet\Control\N
3720: 6c 73 5c 43 6f 64 65 50 61 67 65 7d 20 41 43 50 ls\CodePage} ACP
3730: 5d 0d 0a 73 65 74 20 74 63 6c 4e 61 6d 65 20 63 ]..set tclName c
3740: 70 5b 66 6f 72 6d 61 74 20 25 75 20 24 77 69 6e p[format %u $win
3750: 43 6f 64 65 50 61 67 65 5d 0d 0a 69 66 20 7b 24 CodePage]..if {$
3760: 74 63 6c 4e 61 6d 65 20 69 6e 20 5b 65 6e 63 6f tclName in [enco
3770: 64 69 6e 67 20 6e 61 6d 65 73 5d 7d 20 7b 0d 0a ding names]} {..
3780: 20 20 20 20 66 63 6f 6e 66 69 67 75 72 65 20 24 fconfigure $
3790: 63 68 61 6e 20 2d 65 6e 63 6f 64 69 6e 67 20 24 chan -encoding $
37a0: 74 63 6c 4e 61 6d 65 0d 0a 7d 20 65 6c 73 65 20 tclName..} else
37b0: 7b 0d 0a 20 20 20 20 2e 2e 2e 74 72 79 20 73 6f {.. ...try so
37c0: 6d 65 20 6f 74 68 65 72 20 6d 65 74 68 6f 64 2e me other method.
37d0: 2e 2e 0d 0a 7d 0d 0a 60 60 60 0d 0a 0d 0a 23 23 ....}..```....##
37e0: 20 46 75 6c 6c 20 55 6e 69 63 6f 64 65 20 73 75 Full Unicode su
37f0: 70 70 6f 72 74 0d 0a 0d 0a 49 6e 20 54 63 6c 20 pport....In Tcl
3800: 38 2c 20 63 68 61 72 61 63 74 65 72 73 20 6f 75 8, characters ou
3810: 74 73 69 64 65 20 74 68 65 20 42 4d 50 20 77 65 tside the BMP we
3820: 72 65 20 73 74 6f 72 65 64 20 61 73 20 61 20 73 re stored as a s
3830: 75 72 72 6f 67 61 74 65 20 70 61 69 72 0d 0a 61 urrogate pair..a
3840: 6e 64 20 65 66 66 65 63 74 69 76 65 6c 79 20 74 nd effectively t
3850: 72 65 61 74 65 64 20 61 73 20 61 20 73 74 72 69 reated as a stri
3860: 6e 67 20 6f 66 20 6c 65 6e 67 74 68 20 32 2e 20 ng of length 2.
3870: 54 68 69 73 20 69 73 20 6e 6f 20 6c 6f 6e 67 65 This is no longe
3880: 72 0d 0a 74 68 65 20 63 61 73 65 20 69 6e 20 54 r..the case in T
3890: 63 6c 20 39 20 77 68 69 63 68 20 68 61 73 20 66 cl 9 which has f
38a0: 75 6c 6c 20 73 75 70 70 6f 72 74 20 66 6f 72 20 ull support for
38b0: 74 68 65 20 65 6e 74 69 72 65 20 55 6e 69 63 6f the entire Unico
38c0: 64 65 20 72 61 6e 67 65 0d 0a 61 6e 64 20 77 69 de range..and wi
38d0: 6c 6c 20 28 63 6f 72 72 65 63 74 6c 79 29 20 74 ll (correctly) t
38e0: 72 65 61 74 20 74 68 65 73 65 20 63 68 61 72 61 reat these chara
38f0: 63 74 65 72 73 20 61 73 20 73 74 72 69 6e 67 73 cters as strings
3900: 20 6f 66 20 6c 65 6e 67 74 68 20 31 2e 0d 0a 0d of length 1....
3910: 0a 41 6e 79 20 77 6f 72 6b 61 72 6f 75 6e 64 73 .Any workarounds
3920: 20 74 6f 20 64 65 61 6c 20 77 69 74 68 20 74 68 to deal with th
3930: 65 73 65 20 73 68 6f 72 74 63 6f 6d 69 6e 67 73 ese shortcomings
3940: 20 69 6e 20 54 63 6c 20 38 20 6e 65 65 64 20 74 in Tcl 8 need t
3950: 6f 20 62 65 0d 0a 72 65 6d 6f 76 65 64 2e 0d 0a o be..removed...
3960: 0d 0a 53 65 65 20 5b 54 49 50 20 34 39 37 5d 28 ..See [TIP 497](
3970: 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 74 63 6c https://core.tcl
3980: 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 73 2f 64 -lang.org/tips/d
3990: 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f 34 39 37 oc/trunk/tip/497
39a0: 2e 6d 64 29 2e 0d 0a 0d 0a 23 23 20 54 72 61 63 .md).....## Trac
39b0: 65 73 20 6f 6e 20 75 70 76 61 72 73 20 6c 69 6e es on upvars lin
39c0: 6b 65 64 20 74 6f 20 61 72 72 61 79 73 0d 0a 0d ked to arrays...
39d0: 0a 49 6e 20 54 63 6c 20 38 2c 20 74 72 61 63 65 .In Tcl 8, trace
39e0: 73 20 73 65 74 20 6f 6e 20 61 6e 20 61 72 72 61 s set on an arra
39f0: 79 20 77 6f 75 6c 64 20 6e 6f 74 20 66 69 72 65 y would not fire
3a00: 20 77 68 65 6e 20 61 6e 20 65 6c 65 6d 65 6e 74 when an element
3a10: 20 6f 66 20 74 68 65 20 61 72 72 61 79 0d 0a 77 of the array..w
3a20: 61 73 20 6d 6f 64 69 66 69 65 64 20 74 68 72 6f as modified thro
3a30: 75 67 68 20 61 6e 20 60 75 70 76 61 72 60 20 6c ugh an `upvar` l
3a40: 69 6e 6b 2e 20 54 68 69 73 20 64 6f 63 75 6d 65 ink. This docume
3a50: 6e 74 65 64 20 62 75 74 20 69 6e 63 6f 6e 67 72 nted but incongr
3a60: 75 65 6e 74 0d 0a 62 65 68 61 76 69 6f 72 20 69 uent..behavior i
3a70: 73 20 66 69 78 65 64 20 69 6e 20 54 63 6c 20 39 s fixed in Tcl 9
3a80: 2e 20 41 72 72 61 79 20 74 72 61 63 65 73 20 77 . Array traces w
3a90: 69 6c 6c 20 66 69 72 65 20 65 76 65 6e 20 77 68 ill fire even wh
3aa0: 65 6e 20 74 68 65 20 65 6c 65 6d 65 6e 74 0d 0a en the element..
3ab0: 69 73 20 61 63 63 65 73 73 65 64 20 74 68 72 6f is accessed thro
3ac0: 75 67 68 20 61 6e 20 60 75 70 76 61 72 60 20 6c ugh an `upvar` l
3ad0: 69 6e 6b 2e 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 ink.....See [TIP
3ae0: 20 36 33 34 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 634](https://co
3af0: 72 65 2e 74 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f re.tcl-lang.org/
3b00: 74 69 70 73 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 tips/doc/trunk/t
3b10: 69 70 2f 36 33 34 2e 6d 64 29 2e 0d 0a 0d 0a 23 ip/634.md).....#
3b20: 23 20 60 67 6c 6f 62 60 20 6e 6f 20 6c 6f 6e 67 # `glob` no long
3b30: 65 72 20 72 61 69 73 65 73 20 61 6e 20 65 72 72 er raises an err
3b40: 6f 72 20 69 66 20 6e 6f 20 66 69 6c 65 73 20 6d or if no files m
3b50: 61 74 63 68 0d 0a 0d 0a 49 6e 20 54 63 6c 20 39 atch....In Tcl 9
3b60: 2c 20 74 68 65 20 60 67 6c 6f 62 60 20 63 6f 6d , the `glob` com
3b70: 6d 61 6e 64 20 72 65 74 75 72 6e 73 20 61 6e 20 mand returns an
3b80: 65 6d 70 74 79 20 6c 69 73 74 20 69 66 20 6e 6f empty list if no
3b90: 20 66 69 6c 65 73 20 6d 61 74 63 68 20 74 68 65 files match the
3ba0: 0d 0a 73 70 65 63 69 66 69 65 64 20 70 61 74 74 ..specified patt
3bb0: 65 72 6e 20 69 6e 73 74 65 61 64 20 72 61 73 69 ern instead rasi
3bc0: 69 6e 67 20 61 6e 20 65 72 72 6f 72 2e 20 54 68 ing an error. Th
3bd0: 69 73 20 69 73 20 74 72 75 65 20 69 72 72 65 73 is is true irres
3be0: 70 65 63 74 69 76 65 20 6f 66 0d 0a 74 68 65 20 pective of..the
3bf0: 70 72 65 73 65 6e 63 65 20 6f 66 20 74 68 65 20 presence of the
3c00: 60 2d 6e 6f 63 6f 6d 70 6c 61 69 6e 60 20 6f 70 `-nocomplain` op
3c10: 74 69 6f 6e 20 77 68 69 63 68 20 69 73 20 73 74 tion which is st
3c20: 69 6c 6c 20 61 63 63 65 70 74 65 64 20 62 75 74 ill accepted but
3c30: 20 68 61 73 0d 0a 6e 6f 20 73 69 67 6e 69 66 69 has..no signifi
3c40: 63 61 6e 63 65 2e 20 41 6e 79 20 73 63 72 69 70 cance. Any scrip
3c50: 74 73 20 74 68 61 74 20 65 78 70 65 63 74 20 61 ts that expect a
3c60: 6e 20 65 72 72 6f 72 20 74 6f 20 62 65 20 72 61 n error to be ra
3c70: 69 73 65 64 20 69 6e 20 73 75 63 68 0d 0a 63 61 ised in such..ca
3c80: 73 65 73 20 77 69 6c 6c 20 6e 65 65 64 20 74 6f ses will need to
3c90: 20 62 65 20 6d 6f 64 69 66 69 65 64 20 74 6f 20 be modified to
3ca0: 63 68 65 63 6b 20 66 6f 72 20 61 6e 20 65 6d 70 check for an emp
3cb0: 74 79 20 6c 69 73 74 20 69 6e 73 74 65 61 64 2e ty list instead.
3cc0: 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 20 36 33 37 ....See [TIP 637
3cd0: 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 74 ](https://core.t
3ce0: 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 73 cl-lang.org/tips
3cf0: 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f 36 /doc/trunk/tip/6
3d00: 33 37 2e 6d 64 29 2e 0d 0a 0d 0a 23 23 20 52 65 37.md).....## Re
3d10: 6d 6f 76 61 6c 20 6f 66 20 64 65 70 72 65 63 61 moval of depreca
3d20: 74 65 64 20 63 6f 6d 6d 61 6e 64 73 20 6f 72 20 ted commands or
3d30: 61 72 67 75 6d 65 6e 74 73 0d 0a 0d 0a 54 68 65 arguments....The
3d40: 73 65 20 63 6f 6d 6d 61 6e 64 73 20 6f 72 20 61 se commands or a
3d50: 72 67 75 6d 65 6e 74 73 20 68 61 76 65 20 62 65 rguments have be
3d60: 65 6e 20 64 65 70 72 65 63 61 74 65 64 20 61 6e en deprecated an
3d70: 64 20 68 61 76 65 20 62 65 65 6e 20 72 65 6d 6f d have been remo
3d80: 76 65 64 20 66 72 6f 6d 20 54 63 6c 20 39 2e 0d ved from Tcl 9..
3d90: 0a 53 63 72 69 70 74 73 20 6d 61 6b 69 6e 67 20 .Scripts making
3da0: 75 73 65 20 6f 66 20 74 68 65 73 65 20 73 68 6f use of these sho
3db0: 75 6c 64 20 62 65 20 6d 6f 64 69 66 69 65 64 20 uld be modified
3dc0: 61 73 20 62 65 6c 6f 77 3a 0d 0a 0d 0a 2a 20 52 as below:....* R
3dd0: 65 70 6c 61 63 65 20 60 63 61 73 65 60 20 77 69 eplace `case` wi
3de0: 74 68 20 60 73 77 69 74 63 68 60 0d 0a 2a 20 52 th `switch`..* R
3df0: 65 70 6c 61 63 65 20 60 72 65 61 64 20 3c 63 68 eplace `read <ch
3e00: 61 6e 3e 20 6e 6f 6e 65 77 6c 69 6e 65 60 20 77 an> nonewline` w
3e10: 69 74 68 20 60 72 65 61 64 20 2d 6e 6f 6e 65 77 ith `read -nonew
3e20: 6c 69 6e 65 20 3c 63 68 61 6e 3e 60 0d 0a 2a 20 line <chan>`..*
3e30: 52 65 70 6c 61 63 65 20 60 70 75 74 73 20 3c 63 Replace `puts <c
3e40: 68 61 6e 3e 20 3c 6c 69 6e 65 3e 20 6e 6f 6e 65 han> <line> none
3e50: 77 6c 69 6e 65 60 20 77 69 74 68 20 60 70 75 74 wline` with `put
3e60: 73 20 2d 6e 6f 6e 65 77 6c 69 6e 65 20 3c 63 68 s -nonewline <ch
3e70: 61 6e 3e 20 3c 6c 69 6e 65 3e 60 0d 0a 0d 0a 53 an> <line>`....S
3e80: 65 65 20 5b 54 49 50 20 34 38 35 5d 28 68 74 74 ee [TIP 485](htt
3e90: 70 73 3a 2f 2f 63 6f 72 65 2e 74 63 6c 2d 6c 61 ps://core.tcl-la
3ea0: 6e 67 2e 6f 72 67 2f 74 69 70 73 2f 64 6f 63 2f ng.org/tips/doc/
3eb0: 74 72 75 6e 6b 2f 74 69 70 2f 34 38 35 2e 6d 64 trunk/tip/485.md
3ec0: 29 0d 0a 0d 0a 23 23 20 44 65 70 72 65 63 61 74 )....## Deprecat
3ed0: 65 64 20 60 74 72 61 63 65 60 20 73 75 62 63 6f ed `trace` subco
3ee0: 6d 6d 61 6e 64 73 20 60 76 61 72 69 61 62 6c 65 mmands `variable
3ef0: 60 2c 20 60 76 64 65 6c 65 74 65 60 2c 20 60 76 `, `vdelete`, `v
3f00: 69 6e 66 6f 60 20 68 61 76 65 20 62 65 65 6e 20 info` have been
3f10: 72 65 6d 6f 76 65 64 0d 0a 0d 0a 54 68 65 73 65 removed....These
3f20: 20 63 6f 6d 6d 61 6e 64 73 20 68 61 76 65 20 62 commands have b
3f30: 65 65 6e 20 64 65 70 72 65 63 61 74 65 64 20 73 een deprecated s
3f40: 69 6e 63 65 20 54 63 6c 20 38 2e 34 20 61 6e 64 ince Tcl 8.4 and
3f50: 20 68 61 76 65 20 62 65 65 6e 20 72 65 6d 6f 76 have been remov
3f60: 65 64 20 66 72 6f 6d 20 54 63 6c 20 39 2e 0d 0a ed from Tcl 9...
3f70: 53 63 72 69 70 74 73 20 6d 61 6b 69 6e 67 20 75 Scripts making u
3f80: 73 65 20 6f 66 20 74 68 65 73 65 20 73 68 6f 75 se of these shou
3f90: 6c 64 20 62 65 20 6d 6f 64 69 66 69 65 64 20 61 ld be modified a
3fa0: 73 20 62 65 6c 6f 77 3a 0d 0a 0d 0a 2a 20 52 65 s below:....* Re
3fb0: 70 6c 61 63 65 20 60 74 72 61 63 65 20 76 61 72 place `trace var
3fc0: 69 61 62 6c 65 60 20 77 69 74 68 20 60 74 72 61 iable` with `tra
3fd0: 63 65 20 61 64 64 20 76 61 72 69 61 62 6c 65 60 ce add variable`
3fe0: 0d 0a 0d 0a 2a 20 52 65 70 6c 61 63 65 20 60 74 ....* Replace `t
3ff0: 72 61 63 65 20 76 64 65 6c 65 74 65 60 20 77 69 race vdelete` wi
4000: 74 68 20 60 74 72 61 63 65 20 72 65 6d 6f 76 65 th `trace remove
4010: 20 76 61 72 69 61 62 6c 65 60 0d 0a 0d 0a 2a 20 variable`....*
4020: 52 65 70 6c 61 63 65 20 60 74 72 61 63 65 20 76 Replace `trace v
4030: 69 6e 66 6f 60 20 77 69 74 68 20 60 74 72 61 63 info` with `trac
4040: 65 20 69 6e 66 6f 20 76 61 72 69 61 62 6c 65 60 e info variable`
4050: 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 20 36 37 33 ....See [TIP 673
4060: 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 74 ](https://core.t
4070: 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 73 cl-lang.org/tips
4080: 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f 36 /doc/trunk/tip/6
4090: 37 33 2e 6d 64 29 2e 0d 0a 0d 0a 23 23 20 52 65 73.md).....## Re
40a0: 6d 6f 76 61 6c 20 6f 66 20 60 74 63 6c 5f 70 72 moval of `tcl_pr
40b0: 65 63 69 73 69 6f 6e 60 0d 0a 0d 0a 54 68 65 20 ecision`....The
40c0: 6c 6f 6e 67 20 64 65 70 72 65 63 61 74 65 64 20 long deprecated
40d0: 76 61 72 69 61 62 6c 65 20 60 74 63 6c 5f 70 72 variable `tcl_pr
40e0: 65 63 69 73 69 6f 6e 60 20 74 68 61 74 20 63 6f ecision` that co
40f0: 6e 74 72 6f 6c 6c 65 64 20 63 6f 6e 76 65 72 73 ntrolled convers
4100: 69 6f 6e 0d 0a 6f 66 20 66 6c 6f 61 74 69 6e 67 ion..of floating
4110: 20 70 6f 69 6e 74 20 6e 75 6d 62 65 72 73 20 74 point numbers t
4120: 6f 20 73 74 72 69 6e 67 73 20 68 61 73 20 62 65 o strings has be
4130: 65 6e 20 72 65 6d 6f 76 65 64 2e 20 55 73 65 20 en removed. Use
4140: 74 68 65 20 60 66 6f 72 6d 61 74 60 0d 0a 63 6f the `format`..co
4150: 6d 6d 61 6e 64 20 69 6e 73 74 65 61 64 20 74 6f mmand instead to
4160: 20 63 6f 6e 74 72 6f 6c 20 6e 75 6d 62 65 72 20 control number
4170: 6f 66 20 64 69 67 69 74 73 20 67 65 6e 65 72 61 of digits genera
4180: 74 65 64 2e 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 ted.....See [TIP
4190: 20 34 38 38 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 488](https://co
41a0: 72 65 2e 74 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f re.tcl-lang.org/
41b0: 74 69 70 73 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 tips/doc/trunk/t
41c0: 69 70 2f 34 38 38 2e 6d 64 29 2e 0d 0a 0d 0a 23 ip/488.md).....#
41d0: 23 20 5a 69 70 66 73 20 66 69 6c 65 20 73 79 73 # Zipfs file sys
41e0: 74 65 6d 0d 0a 0d 0a 54 63 6c 20 39 20 69 6e 74 tem....Tcl 9 int
41f0: 72 6f 64 75 63 65 73 20 74 68 65 20 61 62 69 6c roduces the abil
4200: 69 74 79 20 74 6f 20 65 6d 62 65 64 20 73 63 72 ity to embed scr
4210: 69 70 74 73 20 61 73 20 61 20 7a 69 70 20 61 72 ipts as a zip ar
4220: 63 68 69 76 65 0d 0a 62 6f 75 6e 64 20 74 6f 20 chive..bound to
4230: 61 6e 20 65 78 65 63 75 74 61 62 6c 65 20 6f 72 an executable or
4240: 20 73 68 61 72 65 64 20 6c 69 62 72 61 72 79 2e shared library.
4250: 20 54 68 65 20 64 65 66 61 75 6c 74 20 62 75 69 The default bui
4260: 6c 64 20 69 73 20 63 6f 6e 66 69 67 75 72 65 64 ld is configured
4270: 20 74 6f 20 6d 61 6b 65 0d 0a 75 73 65 20 6f 66 to make..use of
4280: 20 74 68 69 73 20 63 61 70 61 62 69 6c 69 74 79 this capability
4290: 20 61 6e 64 20 62 69 6e 64 73 20 74 68 65 20 54 and binds the T
42a0: 63 6c 20 69 6e 69 74 69 61 6c 69 7a 61 74 69 6f cl initializatio
42b0: 6e 20 61 6e 64 20 73 75 70 70 6f 72 74 20 73 63 n and support sc
42c0: 72 69 70 74 73 0d 0a 69 6e 74 6f 20 74 68 65 20 ripts..into the
42d0: 73 68 61 72 65 64 20 6c 69 62 72 61 72 79 20 28 shared library (
42e0: 66 6f 72 20 73 68 61 72 65 64 20 62 75 69 6c 64 for shared build
42f0: 73 29 20 6f 72 20 65 78 65 63 75 74 61 62 6c 65 s) or executable
4300: 20 28 66 6f 72 20 73 74 61 74 69 63 20 62 75 69 (for static bui
4310: 6c 64 73 29 2e 0d 0a 46 72 6f 6d 20 61 20 73 63 lds)...From a sc
4320: 72 69 70 74 69 6e 67 20 70 65 72 73 70 65 63 74 ripting perspect
4330: 69 76 65 2c 20 74 68 69 73 20 68 61 73 20 73 65 ive, this has se
4340: 76 65 72 61 6c 20 72 61 6d 69 66 69 63 61 74 69 veral ramificati
4350: 6f 6e 73 20 69 6e 20 74 65 72 6d 73 20 6f 66 0d ons in terms of.
4360: 0a 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 3a 0d .compatibility:.
4370: 0a 0d 0a 2a 20 54 68 65 72 65 20 69 73 20 6e 65 ...* There is ne
4380: 77 20 66 69 6c 65 20 73 79 73 74 65 6d 20 74 79 w file system ty
4390: 70 65 20 60 7a 69 70 66 73 60 20 77 69 74 68 20 pe `zipfs` with
43a0: 69 74 73 20 6f 77 6e 20 72 75 6c 65 73 20 66 6f its own rules fo
43b0: 72 20 66 69 6c 65 20 6e 61 6d 65 73 0d 0a 61 6e r file names..an
43c0: 64 20 64 69 72 65 63 74 6f 72 69 65 73 2e 20 49 d directories. I
43d0: 6e 20 70 61 72 74 69 63 75 6c 61 72 2c 20 6e 61 n particular, na
43e0: 6d 65 73 20 61 72 65 20 63 61 73 65 20 73 65 6e mes are case sen
43f0: 73 69 74 69 76 65 20 65 76 65 6e 20 6f 6e 20 57 sitive even on W
4400: 69 6e 64 6f 77 73 2e 20 4f 74 68 65 72 0d 0a 64 indows. Other..d
4410: 69 66 66 65 72 65 6e 63 65 73 20 69 6e 63 6c 75 ifferences inclu
4420: 64 65 20 64 69 73 61 6c 6c 6f 77 69 6e 67 20 6f de disallowing o
4430: 66 20 63 72 65 61 74 69 6f 6e 20 6f 66 20 6e 65 f creation of ne
4440: 77 20 66 69 6c 65 73 20 61 6e 64 20 64 69 72 65 w files and dire
4450: 63 74 6f 72 69 65 73 2e 20 45 78 69 73 74 69 6e ctories. Existin
4460: 67 0d 0a 66 69 6c 65 73 20 6d 61 79 20 62 65 20 g..files may be
4470: 6d 6f 64 69 66 69 65 64 20 62 75 74 20 74 68 65 modified but the
4480: 20 63 68 61 6e 67 65 73 20 61 72 65 20 6e 6f 74 changes are not
4490: 20 70 65 72 73 69 73 74 65 64 20 74 6f 20 64 69 persisted to di
44a0: 73 6b 20 61 6e 64 20 61 72 65 20 6c 6f 73 74 0d sk and are lost.
44b0: 0a 61 66 74 65 72 20 64 69 73 6d 6f 75 6e 74 69 .after dismounti
44c0: 6e 67 20 74 68 65 20 61 72 63 68 69 76 65 2e 20 ng the archive.
44d0: 53 65 65 20 74 68 65 20 60 7a 69 70 66 73 60 20 See the `zipfs`
44e0: 6d 61 6e 70 61 67 65 20 66 6f 72 20 64 65 74 61 manpage for deta
44f0: 69 6c 73 2e 0d 0a 0d 0a 2a 20 54 68 65 20 66 65 ils.....* The fe
4500: 61 74 75 72 65 20 68 61 73 20 74 68 65 20 73 69 ature has the si
4510: 64 65 20 65 66 66 65 63 74 20 6f 66 20 69 6e 74 de effect of int
4520: 72 6f 64 75 63 69 6e 67 20 74 68 65 20 63 6f 6e roducing the con
4530: 63 65 70 74 20 6f 66 20 76 6f 6c 75 6d 65 73 0d cept of volumes.
4540: 0a 6f 6e 20 55 6e 69 78 20 28 57 69 6e 64 6f 77 .on Unix (Window
4550: 73 20 70 72 6f 67 72 61 6d 6d 65 72 73 20 61 6c s programmers al
4560: 72 65 61 64 79 20 68 61 64 20 74 6f 20 64 65 61 ready had to dea
4570: 6c 20 77 69 74 68 20 64 72 69 76 65 73 20 61 73 l with drives as
4580: 20 76 6f 6c 75 6d 65 73 29 2e 0d 0a 0d 0a 60 60 volumes).....``
4590: 60 0d 0a 20 20 20 20 20 20 20 20 25 20 66 69 6c `.. % fil
45a0: 65 20 76 6f 6c 75 6d 65 73 0d 0a 20 20 20 20 20 e volumes..
45b0: 20 20 20 2f 2f 7a 69 70 66 73 3a 2f 20 2f 0d 0a //zipfs:/ /..
45c0: 60 60 60 0d 0a 0d 0a 2a 20 4f 6e 65 20 69 6d 70 ```....* One imp
45d0: 6c 69 63 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 lication of the
45e0: 61 62 6f 76 65 20 69 73 20 74 68 61 74 20 73 65 above is that se
45f0: 61 72 63 68 65 73 20 66 6f 72 20 66 69 6c 65 73 arches for files
4600: 20 63 61 6e 20 6e 6f 20 6c 6f 6e 67 65 72 20 73 can no longer s
4610: 69 6d 70 6c 79 20 62 65 67 69 6e 0d 0a 61 74 20 imply begin..at
4620: 60 2f 60 20 62 75 74 20 6e 65 65 64 20 74 6f 20 `/` but need to
4630: 69 74 65 72 61 74 65 20 61 63 72 6f 73 73 20 61 iterate across a
4640: 6c 6c 20 76 6f 6c 75 6d 65 73 2e 0d 0a 0d 0a 2a ll volumes.....*
4650: 20 54 68 65 20 70 61 74 68 73 20 77 69 74 68 69 The paths withi
4660: 6e 20 60 61 75 74 6f 5f 70 61 74 68 60 20 2a 6d n `auto_path` *m
4670: 61 79 2a 20 70 6f 69 6e 74 20 74 6f 20 6c 6f 63 ay* point to loc
4680: 61 74 69 6f 6e 73 20 77 69 74 68 69 6e 20 74 68 ations within th
4690: 65 20 60 7a 69 70 66 73 60 20 76 6f 6c 75 6d 65 e `zipfs` volume
46a0: 2e 0d 0a 54 68 65 73 65 20 61 72 65 20 6e 6f 74 ...These are not
46b0: 20 77 72 69 74 61 62 6c 65 20 73 6f 20 61 6e 79 writable so any
46c0: 20 69 6e 73 74 61 6c 6c 65 72 73 20 74 68 61 74 installers that
46d0: 20 63 6f 70 79 20 66 69 6c 65 73 20 69 6e 74 6f copy files into
46e0: 20 74 68 61 74 20 6c 6f 63 61 74 69 6f 6e 20 77 that location w
46f0: 69 6c 6c 20 66 61 69 6c 2e 0d 0a 49 6e 73 74 61 ill fail...Insta
4700: 6c 6c 65 72 73 20 73 68 6f 75 6c 64 20 63 68 65 llers should che
4710: 63 6b 20 66 6f 72 20 77 72 69 74 61 62 6c 65 20 ck for writable
4720: 6c 6f 63 61 74 69 6f 6e 73 20 69 6e 20 61 6e 79 locations in any
4730: 20 63 61 73 65 20 62 75 74 20 74 68 69 73 20 63 case but this c
4740: 68 61 6e 67 65 20 77 69 6c 6c 0d 0a 72 65 73 75 hange will..resu
4750: 6c 74 20 69 6e 20 65 72 72 6f 72 73 20 69 6e 20 lt in errors in
4760: 69 6e 73 74 61 6c 6c 65 72 73 20 74 68 61 74 20 installers that
4770: 77 72 69 74 65 20 74 6f 20 64 69 72 65 63 74 6f write to directo
4780: 72 69 65 73 20 69 6e 20 60 61 75 74 6f 5f 70 61 ries in `auto_pa
4790: 74 68 60 20 77 69 74 68 6f 75 74 0d 0a 74 68 65 th` without..the
47a0: 73 65 20 63 68 65 63 6b 73 2e 0d 0a 0d 0a 23 23 se checks.....##
47b0: 20 43 68 61 6e 6e 65 6c 20 6f 70 74 69 6f 6e 20 Channel option
47c0: 2d 65 6f 66 63 68 61 72 20 63 68 61 6e 67 65 0d -eofchar change.
47d0: 0a 0d 0a 43 68 61 6e 6e 65 6c 20 6f 70 74 69 6f ...Channel optio
47e0: 6e 20 2a 2d 65 6f 66 63 68 61 72 2a 20 6f 6e 20 n *-eofchar* on
47f0: 77 72 69 74 65 20 69 73 20 6e 6f 74 20 73 75 70 write is not sup
4800: 70 6f 72 74 65 64 20 61 6e 79 20 6d 6f 72 65 2e ported any more.
4810: 0d 0a 54 68 65 20 64 65 66 61 75 6c 74 20 6f 6e ..The default on
4820: 20 4d 53 2d 57 69 6e 64 6f 77 73 20 66 6f 72 20 MS-Windows for
4830: 63 68 61 6e 6e 65 6c 73 20 69 73 20 6e 6f 77 20 channels is now
4840: 74 68 65 20 65 6d 70 74 79 20 73 74 72 69 6e 67 the empty string
4850: 20 28 6c 69 6b 65 20 6f 6e 20 61 6c 6c 20 6f 74 (like on all ot
4860: 68 65 72 20 70 6c 61 74 66 6f 72 6d 73 29 2e 0d her platforms)..
4870: 0a 0d 0a 60 60 60 0d 0a 25 20 73 65 74 20 74 20 ...```..% set t
4880: 5b 6f 70 65 6e 20 74 65 73 74 2e 74 78 74 20 77 [open test.txt w
4890: 2b 5d 0d 0a 66 69 6c 65 34 36 61 37 30 34 38 0d +]..file46a7048.
48a0: 0a 25 20 66 63 6f 6e 66 69 67 75 72 65 20 24 74 .% fconfigure $t
48b0: 20 2d 65 6f 66 63 68 61 72 0d 0a 25 20 66 63 6f -eofchar..% fco
48c0: 6e 66 69 67 75 72 65 20 24 74 20 2d 65 6f 66 63 nfigure $t -eofc
48d0: 68 61 72 20 7b 61 20 62 7d 0d 0a 62 61 64 20 76 har {a b}..bad v
48e0: 61 6c 75 65 20 66 6f 72 20 2d 65 6f 66 63 68 61 alue for -eofcha
48f0: 72 3a 20 6d 75 73 74 20 62 65 20 6e 6f 6e 2d 4e r: must be non-N
4900: 55 4c 20 41 53 43 49 49 20 63 68 61 72 61 63 74 UL ASCII charact
4910: 65 72 0d 0a 60 60 60 0d 0a 0d 0a 53 65 65 20 5b er..```....See [
4920: 54 49 50 20 36 34 36 5d 28 68 74 74 70 73 3a 2f TIP 646](https:/
4930: 2f 63 6f 72 65 2e 74 63 6c 2d 6c 61 6e 67 2e 6f /core.tcl-lang.o
4940: 72 67 2f 74 69 70 73 2f 64 6f 63 2f 74 72 75 6e rg/tips/doc/trun
4950: 6b 2f 74 69 70 2f 36 34 36 2e 6d 64 29 2e 0d 0a k/tip/646.md)...
4960: 0d 0a 23 23 20 54 68 72 65 61 64 65 64 20 62 75 ..## Threaded bu
4970: 69 6c 64 73 0d 0a 0d 0a 54 63 6c 20 62 75 69 6c ilds....Tcl buil
4980: 64 73 20 61 72 65 20 6e 6f 77 20 74 68 72 65 61 ds are now threa
4990: 64 65 64 20 62 79 20 64 65 66 61 75 6c 74 2e 20 ded by default.
49a0: 54 68 65 20 60 74 63 6c 5f 70 6c 61 74 66 6f 72 The `tcl_platfor
49b0: 6d 28 74 68 72 65 61 64 65 64 29 60 20 76 61 72 m(threaded)` var
49c0: 69 61 62 6c 65 20 69 73 20 6e 6f 20 6c 6f 6e 67 iable is no long
49d0: 65 72 20 64 65 66 69 6e 65 64 2e 0d 0a 54 6f 20 er defined...To
49e0: 63 68 65 63 6b 20 66 6f 72 20 74 68 72 65 61 64 check for thread
49f0: 65 64 20 62 75 69 6c 64 73 20 69 6e 20 61 20 38 ed builds in a 8
4a00: 2e 36 2f 39 20 63 6f 6d 70 61 74 69 62 6c 65 20 .6/9 compatible
4a10: 77 61 79 2c 20 75 73 65 0d 0a 0d 0a 60 60 60 0d way, use....```.
4a20: 0a 74 63 6c 3a 3a 70 6b 67 63 6f 6e 66 69 67 20 .tcl::pkgconfig
4a30: 67 65 74 20 74 68 72 65 61 64 65 64 0d 0a 60 60 get threaded..``
4a40: 60 0d 0a 0d 0a 53 65 65 20 5b 54 49 50 20 34 39 `....See [TIP 49
4a50: 31 5d 28 68 74 74 70 73 3a 2f 2f 63 6f 72 65 2e 1](https://core.
4a60: 74 63 6c 2d 6c 61 6e 67 2e 6f 72 67 2f 74 69 70 tcl-lang.org/tip
4a70: 73 2f 64 6f 63 2f 74 72 75 6e 6b 2f 74 69 70 2f s/doc/trunk/tip/
4a80: 34 39 31 2e 6d 64 29 2e 0a 5a 20 36 65 31 62 34 491.md)..Z 6e1b4
4a90: 39 38 30 32 39 39 32 66 61 31 38 38 32 31 63 38 9802992fa18821c8
4aa0: 66 66 37 61 61 66 39 35 38 32 35 0a ff7aaf95825.