[seqfan] RETURN in Maple

Brendan McKay Brendan.McKay at anu.edu.au
Sun Jan 12 22:59:10 CET 2014


Folks, 

It is quite impossible that Maple will get rid of the concept of
returning a value.  They are just phasing out “RETURN(x)” in
favour of “return x”.  That is, the spelling changed and it
became a statement rather than a function.  The “strong
discouragement” about RETURN is because it is obsolete.

So the code can look like this:

f:=proc(n) option remember; local t1;
if n = 1 then return 1;
elif n mod 2 = 0 then return f(n/2);
else t1:= f(n-2)-f((n-1)/2);
if t1 > 0 then return t1 else return f(n-2)+f((n-1)/2); fi; fi; end;


If that gives wrong values in Maple 17, either there is a bug in the
code or a bug in Maple 17.  I can’t check; I only have Maple 16.

I severely don’t like the new warning.  It is much a stronger claim
than anyone has shown to be true. Much better would be to say
“Newer versions of Maple prefer ‘return x’ rather than ‘RETURN(x)’.”.
Even better, just silently replace “RETURN" by “return”.  The
extra parentheses shouldn’t make any difference and only people
stuck with Maple 5 or earlier will have trouble.

Brendan.



More information about the SeqFan mailing list