Re: Tcl (Itcl) and default parameters/arguments



"MH" <mghembru@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote
> Hi. I'm working in Itcl, and I'm wondering if this is possible:
>
> itcl::class x {
> public variable y;
>
> public method a { {p1 $y} } {
> puts "Value is: $p1"
> }
> }


I don't think that it is possible.

But you can work around it. Use {args}, count the parameters, and do things
the hard way. A little easier, but not quite as robust, is something like:

public method a { {p1 VERY_UNLIKELY_DEFAULT} } {
if { $p1 eq VERY_UNLIKELY_DEFAULT } {
set p1 $y
}
}

Bob
--
Bob Techentin techentin.robert@xxxxxxxxxxxxxx
Mayo Foundation (507) 538-5495
200 First St. SW FAX (507) 284-9171
Rochester MN, 55901 USA http://www.mayo.edu/sppdg/




.



Relevant Pages