Functions
These are just like procedures, but they return a value, and can be
used in an expression, e.g.
Any Phix object can be returned. You can return multiple values, by returning a sequence of objects. e.g.
The general term "subroutine", or simply "routine" is used when a remark is applicable to both procedures and functions.
function getAverage(atom a, atom b) return (a+b)/2 end functionIn general function names should probably begin with a verb, mainly because things like
atom average = average(...)
will simply fail to compile.Any Phix object can be returned. You can return multiple values, by returning a sequence of objects. e.g.
return {x_pos, y_pos}See also: Multiple Assignment
The general term "subroutine", or simply "routine" is used when a remark is applicable to both procedures and functions.