73
edits
Changes
→Overloading
The primer covers procedures including overloading, argument intents and dynamic dispatch.
=== Overloading ===
The prime allows the user to do the overload function. proc factorial(x: int) : int { if x < 0 then halt("factorial -- Sorry, this is not the gamma procedure!"); return if x == 0 then 1 else x * factorial(x-1); }We can and overload the factorial function to accept the 32-bit integers. proc factorial(x: int(32)) : int(32) { if x < 1 then halt("factorial -- Invalid operandoperators."); if x < 3 then return x; return x * (x-1) * factorial(x-2);}
= Reference =