Re: examine or describe a proc?



Uwe Klein <uwe_klein_habertwedt@xxxxxxxxxxx> wrote:
Looking at that, I wonder:
set arglist [info args $procname]
while {[llength $arglist] > 0} {
set varg [lvarpop arglist 0]
Can't this be equivalently, but very much simpler, be done as
foreach varg [info args $procname] {

[historical-reasons speculation snipped]

generally it depends:
if [lvarpop] is used more than once in the foreach body,
|| (the loop can be "break"ed out of
&& remaining $arglist is used after that)
then you can't replace it with foreach,
else you can. :-)

Looking at showproc, it seems like the else-branch applies.

Btw, there is also a bug in the code!
If some argument does not have a default, it should still
be [list]-wrapped

% proc foo {{{bad thing}}} { return ${bad thing} }
% showproc foo ;# -> proc foo {{bad thing}} { return ${bad thing} }

One not-redundant(!) pair of braces has been lost :-(

.