For purpose of illustration, in pseudocode:
function addint(x,y,answer: integer)
var
condition: integer;
begin
if ((MAXINT - x) < y) then
begin
answer := x;
condition := 1;
end
else
begin
answer := x + y;
condition := 0;
end;
return condition;
end.
In the example, answer is either called by reference or is a pointer. It holds the actual result to be passed back to the caller, and the function itself holds the exit code. The exit code follows the C tradition: 0 for normal exit and other values for abnormal exit. It is required because the operation is not always successful, depending on the values of x and y.
Is there anyway to write the same style of functions in Python without major modifications?