wrong#args problem in [apply] guts
Closed / Fixed1574835fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-10-10 21:35:17
% namespace ensemble create -command bar -map {id
{const foo}}
::bar
% proc const val { return $val }
% proc alias {object slot = command args} {
set map [namespace ensemble configure $object -map]
dict set map $slot [linsert $args 0 $command]
namespace ensemble configure $object -map $map
}
% proc method {object name params body} {
set params [linsert $params 0 self]
alias $object $name = ::apply [list $params $body
::] $object
}
% method bar boo x {return "[expr {$x*$x}] - $self"}
% bar ?
unknown or ambiguous subcommand "?": must be boo, or id
% bar boo
wrong # args: should be "bar boo"
That's a wrong error message, should be:
wrong # args: should be "bar boo x"
msoferplain2006-10-11 05:34:02
Logged In: YES
user_id=148712
Oohh ... nasty, the error messages for curried lambdas are
not quite ok.
% set lam [list {self x} {return "[expr {$x*$x}] - $self"}]
{self x} {return "[expr {$x*$x}] - $self"}
% apply $lam bar
wrong # args: should be "apply {{self x} {return "[expr
{$x*$x}] - $self"}} self x"
% interp alias {} try {} apply $lam bar
try
% try
wrong # args: should be "apply {{self x} {return "[expr
{$x*$x}] - $self"}} self x"
That should be instead:
wrong # args: should be "try x"
Or should it?
% interp alias {} try2 {} boo bar
try2
% try2
wrong # args: should be "boo self x"
[Side note: should interp alias rewrite the error message
ust like ensemble aliases? Probably ...]
There is here (I think) some interplay between ::apply
returning such a funny error message (with a two-word
command name, plenty of spaces in there too) and the
ensemble's rewriting rules.
msofer Ticket [1574835fff]: 1 change
[History diff]2006-10-11 05:35:30
msoferplain2006-10-12 08:39:11
File Added - 197791: 1574835.diff
Logged In: YES
user_id=148712
Attached a patch that fixes this particular issue, but
raises some others. It uses ns-ensemble's machinery.
New test failures:
apply-4.1,2: Tcl_WrongNumArgs is quoting where it shouldn't.
---- Result was:
1 {wrong # args: should be "apply {{x {set x 1}}} x"}
---- Result should have been (exact matching):
1 {wrong # args: should be "apply {x {set x 1}} x"}
Apply-6.2,3: [info level] does not know about ensemble
rewriting. I think it should.
set lambda [list args {info level 0}]
apply $lambda x y
---- Result was:
{args {info level 0}} x y
---- Result should have been (exact matching):
apply {args {info level 0}} x y
msoferplain2006-10-12 08:44:20
Logged In: YES
user_id=148712
To illustrate that the problem is at least partially with
[info level]:
% proc foo {} {info level 0}
% alias bar boo = foo
% bar boo
::foo
dgpplain2006-10-12 21:03:35
Logged In: YES user_id=80530 Looks like you're re-opening the issues from 217806, 218638, 218015. The *really* important issue in those reports got corrected, but the incompat in [info level] data remained.
msoferplain2006-10-15 10:03:44
Logged In: YES user_id=148712 See also [Bug 1577492] for a solution to the [info level] problem.
msoferplain2006-10-24 05:53:52
Logged In: YES user_id=148712 Patch in [Bug 1577492] has been committed, this patch should be adapted so that [interp alias] benefits too.
msoferplain2006-10-24 07:37:15
Logged In: YES user_id=148712 Fixed in HEAD, tests missing.
msofer Ticket [1574835fff]: 1 change
[History diff]2006-10-24 07:37:16
msoferplain2006-10-25 06:13:09
Logged In: YES user_id=148712 Added apply-4.3-5
Log in (anonymous is fine) to add a comment.
Attachments:
- 1574835.diff [download] added by msofer on 2006-10-12 08:39:11. [details]