Try using 'eval'. It will expand the list for you and feed it to the
proc. So, for

proc xyzzy1 {arg1 args} {
  return [eval xyzzy0 $arg1 $args]
}

proc xyzzy2 {arg1 args} {
  return [eval xyzzy1 $arg1 $args]
}

You could also for xyzzy0 and xyzzy1, use a variable instead of 'args',
and treat that variable as a list. This would work unless these procs
are used elsewhere, where there truly is an unknown number of arguments.


HTH,

    --brett



On Sat, 2002-05-25 at 14:28, [EMAIL PROTECTED] wrote:
> TCL (we're on 7.6) has a special variable name "args" for variable
> arguments.  It seems to work fine for 1 level, but I'm confused if/how
> it can be used for multiple procedure levels since it "listifies" its
> argument on every procedure call.
>
> For example, in this test program, passing "args" to lower level
> procedures keeps modifying the argument, but I really want it to stay
> the same:
>
> proc xyzzy0 {arg1 args} {
>   return "
> arg1=$arg1
> args=$args
> llength=[llength $args]
> 1st el=[lindex $args 0]
> "
> }
>
> proc xyzzy1 {arg1 args} {
>   return [xyzzy0 $arg1 $args]
> }
>
> proc xyzzy2 {arg1 args} {
>   return [xyzzy1 $arg1 $args]
> }
>
> ns_return 200 text/plain "
> xyzzy0: [xyzzy0 a1 "a2 a3" "a4 a5"]
>
> xyzzy1: [xyzzy1 a1 "a2 a3" "a4 a5"]
>
> xyzzy2: [xyzzy2 a1 "a2 a3" "a4 a5"]
> "
> return
>
>
> Here's the output:
>
> xyzzy0:
> arg1=a1
> args={a2 a3} {a4 a5}         --- this one is what I expected
> llength=2
> 1st el=a2 a3
>
>
> xyzzy1:
> arg1=a1
> args={{a2 a3} {a4 a5}}
> llength=1
> 1st el={a2 a3} {a4 a5}
>
>
> xyzzy2:
> arg1=a1
> args={{{a2 a3} {a4 a5}}}
> llength=1
> 1st el={{a2 a3} {a4 a5}}
>
>
> Is there a way to "unlistify" $args before passing it to a lower level
> proc?  Or is there a better/right way to do this?
>
> Any advice appreciated.
>
> Jim
--
Brett Schwarz
brett_schwarz AT yahoo.com

Reply via email to