Re: [TCL] Help debugging behavior in new source command
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: [TCL] Help debugging behavior in new source command

From: Schelte Bron <nospam@wanadoo.nl>
Date: Thu Apr 13 2006 - 22:55:18 CEST

Andrew Falanga wrote:
>>> uplevel #0 [list _source] $pathToFile
>>
>> This should be:
>>
>> uplevel 1 [list _source $pathToFile]
>>
>> The revised [list] arguments are in order to support values
>> of $pathToFile that contain spaces. That's the whole point of
>> [list] quoting. Just [list _source] alone is essentially
>> [pointless.
>
> Honestly, it seemed that way to me too. However, I was going off
> of a thread "extend Tcl commands? no can do?" originally posted to
> this list
> Oct. 3, 2000 by a p_lavarre. In this thread a Dan Kuchler advised
> the OP that his redefinition of the source command should look
> like this:
>
> proc ::source {args} {
> puts test
> return [uplevel [list source_orig] $args]
> }
>
> With the exception of the return addition, he had what I wrote.

No he hadn't. There's one very significant difference: Dan used the
special argument "args". If the last argument to a proc is called
args, it will contain *a list of* the remaining arguments. Any
argument named differently will only contain the value of a single
argument. This is why your argument should be included inside the
list statement while it shouldn't be in case of using "args".

Schelte.

-- 
set Reply-To [string map {nospam schelte} $header(From)]
Received on Sun Apr 30 03:10:58 2006