Generate an error on default arg followed by non-default arg
Open1665441fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 18 years ago
Descriptionplain2007-02-21 17:25:36
The proc command should raise an error if a non-default argument follows a defaulted argument.
gwlesterplain2007-02-22 00:25:37
File Added - 217069: tclProc.c
msoferplain2007-02-22 00:30:13
Logged In: YES user_id=148712 Originator: NO Please submit the patch as patch, not the full file! 'diff -u' is what we prefer ...
msofer Ticket [1665441fff]: 2 changes
[History diff]2007-02-22 00:30:53
pspjuthplain2007-02-22 14:35:42
Logged In: YES
user_id=98900
Originator: NO
While adding such sanity checks, it might be good to check
for duplicate arguments too.
proc a {x x} { puts [info locals] }
is currently allowed but nonsensical.
msoferplain2007-02-23 02:52:39
Logged In: YES user_id=148712 Originator: NO Duplicate arguments is not itself an error; there might even be someone out there (mis)using that (mis)feature?
pspjuthplain2007-02-23 19:09:30
Logged In: YES
user_id=98900
Originator: NO
I think you are right, I can imagine someone using duplicate args for
dummy args like:
proc a {x _ _ y} {...}
so, consider my request withdrawn.
lars_hplain2007-02-27 19:33:40
Logged In: YES
user_id=938835
Originator: NO
Has the issue of how this is documented been considered?
The [proc] manpage (8.5 currently on www.tcl.tk) says:
Arguments with default values need not be specified in a procedure invocation. However, there must be enough actual arguments for all the formal arguments that don't have defaults, and there must not be any extra actual arguments.
It does /not/ say arguments with defaults may only be given at the end. Even the error messages seem to agree with this, although an error is thrown:
% info patchlevel
8.5a3
% proc prov {{opt 23} man} {list $opt $man}
% prov 1
wrong # args: should be "prov ?opt? man"
% prov 1 2
1 2
msofer Ticket [1665441fff]: 1 change
[History diff]2009-05-01 08:30:08
Log in (anonymous is fine) to add a comment.
Attachments:
- tclProc.c [download] added by gwlester on 2007-02-22 00:25:37. [details]