Check-in [de82360011]

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

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

Overview
Comment:Tidy up 523
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:de82360011e45066d3c012a7c971bf57f27727ae750e4e8ca641475df99942be
User & Date: pspjuth 2018-10-27 17:08:20
Context
2018-10-27
17:28
Editorial pass for TIP 523 check-in: 21f784d0d3 user: dkf tags: trunk
17:08
Tidy up 523 check-in: de82360011 user: pspjuth tags: trunk
14:42
Editorial tidy up for TIP 518 check-in: e531f63c61 user: dkf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tip/523.md.

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
	set stack [lrange [K $stack [set stack {}]] 0 end-1]

To support both queue and stack the pop end needs to be chosen, and the easiest
way is to have an index argument. This trivially extends the functionality to
remove any element.

Further, making it use multiple indices in the same way as lindex and lset does
gives more symmetry and together with lset's ability to add to a sublist,
doing push/pop on a sublist becomes feasible.
The ability in lset and lindex to get an index list is not supported since
argument expansion covers that usage.

Since deleting last is rather common (stack) and also the cheapest operation,
that is selected as default when no index is given.

................................................................................
## Name

Many alternative command names have been proposed.

lpop, ltake, lremove, ltrunc, (Hunter Green #355E3B)

No name will ever fully explain what it does or match all users' expectations
of that that name means. "lpop" is close enough and short.

## Error

Should an out of range index be an error or a no-op returning ""?

Empty, for symmetry with lindex.

................................................................................

## Pop Multiple

It was proposed to be able to pop more than one element.
This could be an index list in last index, or an option:

	lpop listVar ?index ...? {0 1)
        lpop -n 2 listVar
        lpop -gather {0 3 7} listVar

This should take careful consideration since having a command that sometimes
returns a list and sometimes an element should not be taken lightly.
Any of the above versions are possible extensions to the current TIP.

# Copyright

This document has been placed in the public domain.







|







 







|







 







|
|








36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
..
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
	set stack [lrange [K $stack [set stack {}]] 0 end-1]

To support both queue and stack the pop end needs to be chosen, and the easiest
way is to have an index argument. This trivially extends the functionality to
remove any element.

Further, making it use multiple indices in the same way as lindex and lset does
gives more symmetry. Together with lset's ability to add to a sublist,
doing push/pop on a sublist becomes feasible.
The ability in lset and lindex to get an index list is not supported since
argument expansion covers that usage.

Since deleting last is rather common (stack) and also the cheapest operation,
that is selected as default when no index is given.

................................................................................
## Name

Many alternative command names have been proposed.

lpop, ltake, lremove, ltrunc, (Hunter Green #355E3B)

No name will ever fully explain what it does or match all users' expectations
of what that name means. "lpop" is close enough and short.

## Error

Should an out of range index be an error or a no-op returning ""?

Empty, for symmetry with lindex.

................................................................................

## Pop Multiple

It was proposed to be able to pop more than one element.
This could be an index list in last index, or an option:

	lpop listVar ?index ...? {0 1)
	lpop -n 2 listVar
	lpop -gather {0 3 7} listVar

This should take careful consideration since having a command that sometimes
returns a list and sometimes an element should not be taken lightly.
Any of the above versions are possible extensions to the current TIP.

# Copyright

This document has been placed in the public domain.