> On Fri, 14 Jan 2000, John N S Gill wrote:
> 
> > I don't think it is true to say that eval doesn't do anything with one 
> > arguement.  Eg
> > 
> > % proc x {args} {   
> > puts $args
> > puts [llength $args]
> > }
> > %  x {a b c}
> > {a b c}
> > 1
> > % eval x {a b c}
> > a b c
> > 3
> 
> Ha! Look again! you gave eval 2 args (x and the list), not one!

Good point, I can't count, but:

% proc x args {
puts $args
puts [llength $args]
}

% eval {x a b c}
a b c
3
% x a b c
a b c
3
% {x a b c}
invalid command name "x a b c"
% 

What you get with eval is an extra application of the TCL parser.  By 
passing the (single) arguement to eval you use the parser to strip 
off the quoting {}'s.  eval then passes the result on the parser.  
This isn't quite a matter of doing nothing.  

If eval was doing nothing when called with one argument it ought to 
be equivalent to:

proc ee args {
$args
}

But:
% ee {x a b c}

gives:
invalid command name "{x a b c}"


> Also, proc x {args} is a very special case of "args". 

err yes.. that was precisely why I was using it.  I wanted a command 
that wouldn't mind how many arguments it was called with.


---------------------------------------------------------------------------
To unsubscribe from the Visual Tcl mailing list, please send a message
to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
message body (where [EMAIL PROTECTED] is your e-mail address).

Reply via email to