jk...@ik... wrote:
> Arguably Matlab has the elegant Lisp-like feature lacking in Python of
> multiple return values. In Lisp you can write
>
> (setq x (floor 3.14))
>
> to set the value of x to 3, or
>
> (multiple-value-setq (x y) (floor 3.14))
>
> to set the value of x to 3 and the value of y to 0.14. Note how it is
> left up to the caller of the FLOOR function whether to capture just
> the first returned value or both of them. This is paralleled by
> Matlab's
>
> x = some_function(a,b,c)
> [x,y] = some_function(a,b,c)
>
> where the caller decides how many values will be returned.
Note that you can simply "emulate" this missing Python feature by
appending indexes after your function call:
x = some_function(a,b,c)[0]
x, y = some_function(a,b,c)[:2]
and so on...
Naturally this does not save computation as nargout could do, but is
this really an issue? IMHO this is generally not.
JM. Philippe
|