| Ticket UUID: | 558299 | ||
| Title: | restrict use of proc argument named args | ||
| Type: | RFE | Created on: | 2002-05-20 14:46:02 |
| Submitter: | lvirden | Assigned to: | msofer |
| Subsystem: | 22. [proc] and [uplevel] | Severity: | |
| Priority: | 5 Medium | Last modified: | 2026-11-13 11:18:44 |
| Status: | Closed | Closed by: | serhiy.storchaka |
| Resolution: | Rejected | Closed on: | 2026-11-13 11:18:43 |
| Version: | None | ||
| Description: | ||||
I would like to request a new feature where by the only valid use of a proc argument called 'args' is as the last argument of the proc. It need not of course be present at all - but if it is present, the change would require args to be the last argument. In this way, changes to proc definitions by non-savvy tcl programmers do not break the Tcl behavior of treating args special if it is the last argument. Also, use of args as a 'normal' proc argument is prevented - otherwise, tcl programmers seeing the variable may expect a list of remaining arguments when in fact they are only getting one argument. | ||||
| User Comments: | ||||
dkf added on 2002-05-20 21:52:38:
Logged In: YES
user_id=79902
Alternative that I thought of:
Make args always magical and for it to suck up all args not
used elsewhere (particularly thinking about handling of
fixed suffixes on commands that take options.) This would
make implementing something that looks like, say, [lsearch]
easier as you could declare it as [proc foo {args searchTerm
list} {...}]
vincentdarley added on 2002-05-20 22:24:53:
Logged In: YES
user_id=32170
I like Donal's suggestion a lot. Allowing 'args' as a
first argument would make it much easier to implement any
command that looks like 'cmd ?opts? blah blah'. Given that
commands which look like that are the 'Tcl-way', I think it
would be a great idea.
That would mean we probably want to throw an error for
multiple use of 'args' (i.e. proc {args foo args} {...} is
an error, but then again _any_ multiple use of the same
parameter is most likely an error).
My only worry: anyone who has written code using 'args' as
a non-final parameter has a reasonable chance that the code
might break when this change is made. This represents a
mild backwards compatibility issue, but likely only for
code written by Tcl-beginners.
pspjuth added on 2007-02-22 14:42:33:
Logged In: YES user_id=98900 Originator: NO See also TIP 288 lvirden added on 2007-02-22 19:35:36:
Logged In: YES user_id=15949 Originator: YES hey, I don't mind the idea of args always being special, I guess. It would allow intentional use as Donal described to be done. The original request arose when someone had come along and, not knowing the specialness of args, added an argument after it in a proc, resulting in the code not working. The newly proposed behavior of always being magic is a potential incompatibility, but not any more than my original request... serhiy.storchaka added on 2026-11-13 11:18:44:
The direction agreed on here, making args special anywhere, was TIP 288. That TIP was rejected in 2022, and nobody proposed the incompatible restriction separately. | ||||
