Wrong proc doesn't guives an error
Openfd2d126f231e1c228ff250b220823d76967bd506Created 12 years agoUpdated 12 years ago
Descriptionplain2015-05-16 00:53:50
This proc
proc oneFunction {a {b 1} c} {puts "$a $b $c"}
doesn't guive an error. It's accepted by the interpreter. I think all the optional arguments should be at the end.
dkf Ticket [fd2d126f23]: 4 changes
[History diff]2015-05-16 05:52:37
ferrieuxplain2015-05-16 11:41:33
The reason it is accepted, is that {b 1} is a valid arg name.
I admit it would make sense to forbid whitespace in arg names except for default ones (end of list), but after decades without the rule there's a (small) risk of compat breakage. Maybe for 9.0 ?
dkfhtml2015-05-17 11:06:38
No, each formal argument has always been a list. It's just that proc has simply never checked for this failure mode. At some point we might get around to making optionals-in-the-middle work. But for now, it's a (really) low priority, especially as it is a performance-sensitive area.
Making this be a declaration-time error would be reasonable. The only concern would be how much of an impact on existing (non-working) scripts this would have.
Log in (anonymous is fine) to add a comment.