|
Parameter defaults
|
Pete Lomax
|
Oct 10, 2005 13:26 PDT
|
Seeing if this list is still working...
Let's say we allow optional parameters (by giving them defaults), eg:
function scan(object set, object target=0)
static integer k
k = compare(set[1],target)
if k=0 then
return set[RRES]
elsif k<0 then
return scan(set[LEFT])
else
return scan(set[RIGHT])
end if
end function
Now, in the example I have shown, I have given target a default of 0
so if the routine is called from toplevel with one parameter it will
find a 0. I have also shown the recursive calls don't bother passing
target again, implying the default of 0 shown above is NOT applied to
recursive calls. Does this make sense, is this the right thing to do?
It may get very confusing for mutually recursive routines...
Regards,
Pete
|
|
 |
|