octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Idea: Extension of function / return syntax.


From: John W. Eaton
Subject: Re: Idea: Extension of function / return syntax.
Date: Mon, 7 Jan 2013 13:36:02 -0500

On  7-Jan-2013, Jordi Gutiérrez Hermoso wrote:

| So I just found the first problem with this syntax. What will
| "nargout" return inside a function that does not declare an output
| variable yet uses decorated return statements? We could make it leave
| it at zero, and arguably if you're using both nargout and this new
| syntax you should be considered to be in error. More difficultly,
| perhaps nargout should parse the whole function first to see if there
| is a bare and a non-bare return statement? But then is it possible for
| a function to have both bare and non-bare return statements, in which
| case, what would nargout return?
| 
| New syntax is a very delicate matter... The multiple return arguments
| of Matlab that we have to keep in Octave are very problematic:

I'd be willing to consider this new feature, but we need a complete
proposal first.

We need to handle multiple return arguments with and without explicit
return lists.

We should handle both

  return EXPR
  return (expr-1, expr-2, ...)

We could handle

  function foo (argument-list)
    return ...

as if we had an implicit varargout (but without the variable) and use
the same rules for nargout as are currently used when varargout is
present.

For something like

  function [ret-list] = foo (arg-list)
    return (expr-1, ...)

we could simply fill in the elements of ret-list from the expression
list given in the return statement without having to perform the
variable assignments in advance.

There are probably other issues to consider; I haven't given it a lot
of thought.

In any case, I'm not so excited by this feature that I would volunteer
to make the changes, so someone else will need to propose a patch.
Or, hey, hire me to do it, I could use the money.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]