Check-in [92d93435a6]

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

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

Overview
Comment:format cleanup in TIP 551
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 92d93435a658192e31b6ae56a4192261b82b016585c6626950691087285ef42d
User & Date: griffin 2019-09-16 15:34:30
Context
2019-09-16
15:37
update index for 551 check-in: 978cb15010 user: griffin tags: trunk
15:34
format cleanup in TIP 551 check-in: 92d93435a6 user: griffin tags: trunk
15:29
Added TIP 551 - underscores in numeric literals check-in: 78a116deef user: griffin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tip/551.md.

1
2
3
4
5
6
7
8
9
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# TIP 551: permit underscore in numerical literals in source code
    Author:        [email protected]
    State:         Draft
    Type:          Project
    Vote:          Pending
    Created:       16-Sep-2019
    Post-History:
    Tcl-Version:   8.7
    Keywords:      numbers, readability
................................................................................
would be allowed in the program source code but have no semantic
affect. Any number of underscores would be allowed and their positions
would be unrestricted except where a number would no longer be a
number.

For example,

    `expr 100_000_000`
    `expr 0xffff_ffff`
    `expr 0b1111_1111_1111_1110`

A number is identified in the routine TclParseNumber and scans the
text until the end of the number. It accepts several formats. The key
is that a number is a word that begins with a decimal digit and can
have several forms for decimal, octal, hexidecimal, and binary. The
convention is now to use a 2 character prefix, 0x, 0b, 0o, and the
newest one, 0d. This proposal would allow an underscore following the
first digit or the letter that designates the number base, to anywhere
up to and including the end of the number. There can be multiple
underscores in a row.

Thus,

    `0x_ffff_ffff_`

would be legal and similarly with the other 3 bases supported.

The one restriction would be a number with a leading `_` as that would
change the meaning from a number to a bareword, e.g.

    `expr _123`

would not be allowed, since that would not be a number.

The implementation would be to simply bypass the `_` in all cases during
the processing of the number in the routine TclParseNumber.

The implementation was tested with 4 lines of code at the beginning of
|
|







 







|
|
|

|











|






|







1
2
3
4
5
6
7
8
9
..
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# TIP 551: Permit underscore in numerical literals in source code
    Author:        Eric <[email protected]>
    State:         Draft
    Type:          Project
    Vote:          Pending
    Created:       16-Sep-2019
    Post-History:
    Tcl-Version:   8.7
    Keywords:      numbers, readability
................................................................................
would be allowed in the program source code but have no semantic
affect. Any number of underscores would be allowed and their positions
would be unrestricted except where a number would no longer be a
number.

For example,

    expr 100_000_000
    expr 0xffff_ffff
    expr 0b1111_1111_1111_1110

A number is identified in the routine `TclParseNumber` and scans the
text until the end of the number. It accepts several formats. The key
is that a number is a word that begins with a decimal digit and can
have several forms for decimal, octal, hexidecimal, and binary. The
convention is now to use a 2 character prefix, 0x, 0b, 0o, and the
newest one, 0d. This proposal would allow an underscore following the
first digit or the letter that designates the number base, to anywhere
up to and including the end of the number. There can be multiple
underscores in a row.

Thus,

    0x_ffff_ffff_

would be legal and similarly with the other 3 bases supported.

The one restriction would be a number with a leading `_` as that would
change the meaning from a number to a bareword, e.g.

    expr _123

would not be allowed, since that would not be a number.

The implementation would be to simply bypass the `_` in all cases during
the processing of the number in the routine TclParseNumber.

The implementation was tested with 4 lines of code at the beginning of