This is not necessarily the current version of this TIP.
| TIP: | 289 |
| Title: | Revision of [lrepeat] Argument Order |
| Version: | $Revision: 1.2 $ |
| Author: | Peter Spjuth <peter dot spjuth at space dot se> |
| State: | Draft |
| Type: | Project |
| Tcl-Version: | 8.5 |
| Vote: | Pending |
| Created: | Thursday, 26 October 2006 |
| Keywords: | Tcl |
This TIP proposes to alter the argument order of lrepeat to be similar to string repeat.
In TIP #136, lrepeat is defined as:
lrepeat number element1 ?element2? ?element3? ...
whereas the old string repeat command is:
string repeat string number
This difference between similar commands is bound to cause confusion. Consistency is good.
Change lrepeat's argument order to:
lrepeat element1 ?element2? ?element3? ... number
lrepeat 0 100 - returns list of 100 zeros
lrepeat [lrepeat 0 100] 100 - returns 100x100 matrix (list of lists) of zeros
lrepeat a b c 3 - returns nine-element list {a b c a b c a b c}
lrepeat a b c 1 - identical to [list a b c]
DGP: The main feature that appears to get lost in this change is the ability to redirect aliases or subcommands of ensembles to [lrepeat] calls with the number of repetitions already filled in.
PS: On the other hand, you get the ability to redirect aliases or subcommands of ensembles to [lrepeat] calls with the elements already filled in.
DGP: I skimmed the old TIP 136 messages in the TCLCORE archives. One thing to note is that the existing [lrepeat] syntax in 8.5a5 was chosen in part to be consistent with the existing [struct::list repeat] syntax in the struct::list package.
This document has been placed in the public domain.
This is not necessarily the current version of this TIP.