Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-11-13
11:18 • Closed ticket [558299ffff]: restrict use of proc argument named args plus 6 ... artifact: c73e2d252a user: serhiy.storchaka
2007-02-22
19:35 • Ticket [558299ffff]: 4 changes artifact: f5b4b2a02f user: lvirden
14:42 • Ticket [558299ffff]: 4 changes artifact: 9d626e072c user: pspjuth
2002-05-20
22:24 • Ticket [558299ffff]: 4 changes artifact: 68f8b075a5 user: vincentdarley
21:52 • Ticket [558299ffff]: 4 changes artifact: 797e570706 user: dkf
14:46 • New ticket [558299ffff]. artifact: 582b88eca7 user: lvirden

restrict use of proc argument named args

Closed / Rejected558299ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 19 days ago
Descriptionplain2002-05-20 14:46:02
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.
dkfplain2002-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} {...}]
vincentdarleyplain2002-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.
pspjuthplain2007-02-22 14:42:33
Logged In: YES 
user_id=98900
Originator: NO

See also TIP 288
lvirdenplain2007-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.storchakawiki2026-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.

Log in (anonymous is fine) to add a comment.