Up till now, the definition of a user-function in gretl has
been required to follow this pattern:
function <function-name> (<parameters>)
<function-body>
[ return <return-type> <variable-name> ]
end function
where <...> indicates a placeholder and [...] indicates an
optional element (functions are not required to return anything).
This has served us OK, but it's a bit clunky. Consider writing a
function to multiply a matrix by 2 (I know, pretty silly). The
most compact version would be something like:
function mtwo (matrix m)
x = 2 * m
return matrix x
end function
I've now relaxed the requirement that return lines must match the
pattern above. You can now do
return <expression>
The price you pay for this is that you have to specify the return
type as part of the first line of the definition:
function <return-type> <function-name> (<parameters>)
For example,
function matrix mtwo (matrix m)
return m * 2
end function
For a function that does not return anything you can write
function void <function-name> ...
The old-style syntax is still supported alongside the new.
Eventually we may want to mark it as deprecated and, after a
suitable lag, remove support.
I'm not going to modify the manual on this point for the 1.8.3
release. If people can test the new syntax that would be
great.
Allin