Check-in [9a80a7b5f2]

Login

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

Overview
Comment:Started on discussion in 523
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9a80a7b5f2a71d4b8084e9b2d17f046983acb69992fd82e5eeea4f769ee0010c
User & Date: pspjuth 2018-10-26 21:07:02.275
Context
2018-10-27
01:13
Rebase TIP 506 to apply to Tcl 8.7. check-in: b28cd71459 user: dgp tags: trunk
2018-10-26
21:07
Started on discussion in 523 check-in: 9a80a7b5f2 user: pspjuth tags: trunk
2018-10-24
22:31
Updated lpop to not support index list. check-in: 9cc9a92eab user: pspjuth tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tip/523.md.
57
58
59
60
61
62
63




































64
65
66
The given indices are resolved to an element in the same way as lindex/lset
does, except an index list is not supported, just plain index arguments.
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.





































# Copyright

This document has been placed in the public domain.







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
The given indices are resolved to an element in the same way as lindex/lset
does, except an index list is not supported, just plain index arguments.
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.

# Discussion

## 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.

"It has always seemed wrongheaded to me that commands like lindex return
the empty string when no element exists"

Lpop is not just reading like lindex, it is also removing and there the
symmetry is not evident. Lreplace gives an error for too high indices.

## 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.