Check-in [492f3648fc]

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:TIP 523: New lpop command
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 492f3648fc13652b00bb977c45d7cc910328b1449d2ed2336ee2ebf2dc6b6669
User & Date: pspjuth 2018-10-22 06:43:46
Context
2018-10-22
13:56
Make returns from [fpclassify] lowercase check-in: 43618a48c1 user: kennykb tags: trunk
13:55
Format fixes in 523 check-in: 7d4241ae81 user: pspjuth tags: trunk
06:43
TIP 523: New lpop command check-in: 492f3648fc user: pspjuth tags: trunk
06:00
Updated index check-in: f432da10b0 user: pspjuth tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to index.json.

1

2
3
4
5
6
7
8
...
519
520
521
522
523
524
525
526
527
{"tip": {

	"522":{"url":"./tip/522.md","keywords":"tcltest, error codes","created":"22-Oct-2018","post-history":"","state":"Draft","tcl-branch":"tip-522","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 522: Test error codes with Tcltest","author":["Peter Spjuth <[email protected]>"],"is-jest":false},
	"521":{"url":"./tip/521.md","keywords":"Tcl, floating point, NaN, not a number","created":"21 October 2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 521: Floating Point Classification Functions","author":["Kevin B. Kenny <[email protected]>"],"is-jest":false},
	"520":{"url":"./tip/520.md","keywords":"Tcl, floating point, NaN, not a number","created":"18 October 2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 520: Make NaN Quiet","author":["Kevin B. Kenny <[email protected]>"],"is-jest":false},
	"519":{"url":"./tip/519.md","keywords":"TclOO","":"","state":"Draft","this tip proposes to extend the `method` subcommand of the `oo":":define` command","type":"Project","author":["Pietro Cerutti <[email protected]>"],"follows":"","oo":":define RPCClient {","created":"18-Oct-2018","title":"# TIP 519: Inline export/unexport option to TclOO method definition","the class definition in the previous example would then be as follows":"","post-history":"","vote":"Pending","tcl-version":"8.7","tcl-branch":"tip-519","is-jest":false},
	"518":{"url":"./tip/518.md","keywords":"Tk","created":"22-Sep-2018","post-history":"","state":"Draft","tk-branch":"tip518-event-last-child-unmanaged","tcl-version":"8.7","vote":"Done","type":"Project","title":"# TIP 518: Virtual Event when Last Child is not Managed any more","author":["Harald Oehlmann <[email protected]>"],"is-jest":false},
	"517":{"url":"./tip/517.md","keywords":"tk menu","created":"13-Sept-2018","post-history":"","state":"Final","tk-branch":"tip-517","tcl-version":"8.7","vote":"Done","type":"Project","title":"# TIP 517: Add -activerelief Configuration Option to the menu widget","author":["Francois Vogel <[email protected]>"],"is-jest":false},
	"516":{"url":"./tip/516.md","keywords":"Tcl, TclOO","state":"Final","type":"Project","author":["Donal K. Fellows <[email protected]>"],"vote-results":"4/0/5 accepted","votes-for":"DKF, JN, JD, AK","votes-against":"none","created":"7-Sept-2018","title":"# TIP 516: More OO Slot Operations","post-history":"","tcl-branch":"tip-516","vote":"Done","tcl-version":"8.7","votes-present":"BG, KBK, DGP, FV, SL","is-jest":false},
................................................................................
	"5":{"url":"./tip/5.md","created":"17-Oct-2000","post-history":"","state":"Final","vote":"Done","tcl-version":"8.4","type":"Project","title":"# TIP 5: Make TkClassProcs and TkSetClassProcs Public and Extensible","author":["Eric Melski <[email protected]>"],"is-jest":false},
	"4":{"url":"./tip/4.md","created":"26-Oct-2000","post-history":"","state":"Draft","vote":"Pending","type":"Informative","title":"# TIP 4: Tcl Release and Distribution Philosophy","discussions-to":"news:comp.lang.tcl","author":["Brent Welch <[email protected]>","Donal K. Fellows <[email protected]>","Larry W. Virden <[email protected]>","Larry W. Virden <[email protected]>"],"is-jest":false},
	"3":{"url":"./tip/3.md","created":"14-Sep-2000","post-history":"","state":"Accepted","vote":"Done","type":"Process","title":"# TIP 3: TIP Format","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>"],"is-jest":false},
	"2":{"url":"./tip/2.md","created":"12-Sep-2000","post-history":"","state":"Draft","vote":"Pending","type":"Process","title":"# TIP 2: TIP Guidelines","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>","Don Porter <[email protected]>","Mo DeJong <[email protected]>","Larry W. Virden <[email protected]>","Kevin Kenny <[email protected]>"],"is-jest":false},
	"1":{"url":"./tip/1.md","created":"14-Sep-2000","post-history":"","state":"Active","vote":"No voting","type":"Informational","title":"# TIP 1: TIP Index","author":["TIP Editor <[email protected]>"],"is-jest":false},
	"0":{"url":"./tip/0.md","created":"11-Dec-2000","post-history":"","state":"Final","vote":"Done","type":"Process","title":"# TIP 0: Tcl Core Team Basic Rules","author":["John Ousterhout <[email protected]>"],"is-jest":false},
	"@min": 0,
	"@max": 522
}, "@timestamp": 1540187980}
>







 







|
|
1
2
3
4
5
6
7
8
9
...
520
521
522
523
524
525
526
527
528
{"tip": {
	"523":{"url":"./tip/523.md","keywords":"queue, stack, pop","created":"22-Oct-2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 523: New lpop command","author":["Peter Spjuth <[email protected]>"],"is-jest":false},
	"522":{"url":"./tip/522.md","keywords":"tcltest, error codes","created":"22-Oct-2018","post-history":"","state":"Draft","tcl-branch":"tip-522","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 522: Test error codes with Tcltest","author":["Peter Spjuth <[email protected]>"],"is-jest":false},
	"521":{"url":"./tip/521.md","keywords":"Tcl, floating point, NaN, not a number","created":"21 October 2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 521: Floating Point Classification Functions","author":["Kevin B. Kenny <[email protected]>"],"is-jest":false},
	"520":{"url":"./tip/520.md","keywords":"Tcl, floating point, NaN, not a number","created":"18 October 2018","post-history":"","state":"Draft","tcl-version":"8.7","vote":"Pending","type":"Project","title":"# TIP 520: Make NaN Quiet","author":["Kevin B. Kenny <[email protected]>"],"is-jest":false},
	"519":{"url":"./tip/519.md","keywords":"TclOO","":"","state":"Draft","this tip proposes to extend the `method` subcommand of the `oo":":define` command","type":"Project","author":["Pietro Cerutti <[email protected]>"],"follows":"","oo":":define RPCClient {","created":"18-Oct-2018","title":"# TIP 519: Inline export/unexport option to TclOO method definition","the class definition in the previous example would then be as follows":"","post-history":"","vote":"Pending","tcl-version":"8.7","tcl-branch":"tip-519","is-jest":false},
	"518":{"url":"./tip/518.md","keywords":"Tk","created":"22-Sep-2018","post-history":"","state":"Draft","tk-branch":"tip518-event-last-child-unmanaged","tcl-version":"8.7","vote":"Done","type":"Project","title":"# TIP 518: Virtual Event when Last Child is not Managed any more","author":["Harald Oehlmann <[email protected]>"],"is-jest":false},
	"517":{"url":"./tip/517.md","keywords":"tk menu","created":"13-Sept-2018","post-history":"","state":"Final","tk-branch":"tip-517","tcl-version":"8.7","vote":"Done","type":"Project","title":"# TIP 517: Add -activerelief Configuration Option to the menu widget","author":["Francois Vogel <[email protected]>"],"is-jest":false},
	"516":{"url":"./tip/516.md","keywords":"Tcl, TclOO","state":"Final","type":"Project","author":["Donal K. Fellows <[email protected]>"],"vote-results":"4/0/5 accepted","votes-for":"DKF, JN, JD, AK","votes-against":"none","created":"7-Sept-2018","title":"# TIP 516: More OO Slot Operations","post-history":"","tcl-branch":"tip-516","vote":"Done","tcl-version":"8.7","votes-present":"BG, KBK, DGP, FV, SL","is-jest":false},
................................................................................
	"5":{"url":"./tip/5.md","created":"17-Oct-2000","post-history":"","state":"Final","vote":"Done","tcl-version":"8.4","type":"Project","title":"# TIP 5: Make TkClassProcs and TkSetClassProcs Public and Extensible","author":["Eric Melski <[email protected]>"],"is-jest":false},
	"4":{"url":"./tip/4.md","created":"26-Oct-2000","post-history":"","state":"Draft","vote":"Pending","type":"Informative","title":"# TIP 4: Tcl Release and Distribution Philosophy","discussions-to":"news:comp.lang.tcl","author":["Brent Welch <[email protected]>","Donal K. Fellows <[email protected]>","Larry W. Virden <[email protected]>","Larry W. Virden <[email protected]>"],"is-jest":false},
	"3":{"url":"./tip/3.md","created":"14-Sep-2000","post-history":"","state":"Accepted","vote":"Done","type":"Process","title":"# TIP 3: TIP Format","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>"],"is-jest":false},
	"2":{"url":"./tip/2.md","created":"12-Sep-2000","post-history":"","state":"Draft","vote":"Pending","type":"Process","title":"# TIP 2: TIP Guidelines","author":["Andreas Kupries <[email protected]>","Donal K. Fellows <[email protected]>","Don Porter <[email protected]>","Mo DeJong <[email protected]>","Larry W. Virden <[email protected]>","Kevin Kenny <[email protected]>"],"is-jest":false},
	"1":{"url":"./tip/1.md","created":"14-Sep-2000","post-history":"","state":"Active","vote":"No voting","type":"Informational","title":"# TIP 1: TIP Index","author":["TIP Editor <[email protected]>"],"is-jest":false},
	"0":{"url":"./tip/0.md","created":"11-Dec-2000","post-history":"","state":"Final","vote":"Done","type":"Process","title":"# TIP 0: Tcl Core Team Basic Rules","author":["John Ousterhout <[email protected]>"],"is-jest":false},
	"@min": 0,
	"@max": 523
}, "@timestamp": 1540190587}

Changes to index.md.

116
117
118
119
120
121
122








123
124
125
126
127
128
129
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
<th>Impl.</th>
</tr></thead><tbody>









<tr class='project projectdraft projectdraft87 project87'>
<td valign='top'><a href='./tip/522.md'>522</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 522: Test error codes with Tcltest</td>
<td valign='top'><a href='/tcl/timeline?r=tip-522'>Link</a></td>






>
>
>
>
>
>
>
>







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
<th>Impl.</th>
</tr></thead><tbody>

<tr class='project projectdraft projectdraft87 project87'>
<td valign='top'><a href='./tip/523.md'>523</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 523: New lpop command</td>
<td></td>
</tr>
<tr class='project projectdraft projectdraft87 project87'>
<td valign='top'><a href='./tip/522.md'>522</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.7</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 522: Test error codes with Tcltest</td>
<td valign='top'><a href='/tcl/timeline?r=tip-522'>Link</a></td>

Added tip/523.md.






















































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
# TIP 523: New lpop command
	Author:		Peter Spjuth <[email protected]>
	State:		Draft
	Type:		Project
	Vote:		Pending
	Created:	22-Oct-2018
	Post-History:
	Tcl-Version:	8.7
	Keywords:	queue, stack, pop
-----

Abstract

Add a command to efficiently remove an element from a list.

Rationale

Stacks and queues are common structures to use lists, and thus adding
and removing elements are common operations.
Adding has a direct command through lappend, while removing has less
obvious commands, which also needs tricks like K to avoid performance
problems.

A single command to both retreive the value and remove it is simpler.

	set x [lpop stack]
vs.
	set x [lindex $stack end]
	set stack [lrange $stack 0 end-1]
or even
	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 index lists 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.

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

Specification

A new command is added to the core with the following format.

	lpop listVar ?index ...?

The given index is resolved to an element in the same way as lindex/lset does.
The return value is the element at index, and the list is modified to
remove that element.
If no index is given, the default is "end".
An out of range index is an error.
If index is given as an empty list, that is an error.

# Copyright

This document has been placed in the public domain.