Tcl Source Code

View Ticket
Login
Ticket UUID: 1665441
Title: Generate an error on default arg followed by non-default arg
Type: Bug Version: obsolete: 8.4.14
Submitter: gwlester Created on: 2007-02-21 17:25:36
Subsystem: 22. [proc] and [uplevel] Assigned To: msofer
Priority: 6 Severity:
Status: Open Last Modified: 2009-05-01 08:30:08
Resolution: None Closed By:
    Closed on:
Description:
The proc command should raise an error if a non-default argument follows a defaulted argument.
User Comments: lars_h added on 2007-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

pspjuth added on 2007-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.

msofer added on 2007-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?

pspjuth added on 2007-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.

msofer added on 2007-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 ...

gwlester added on 2007-02-22 00:25:37:

File Added - 217069: tclProc.c

Attachments: