octave-maintainers
[Top][All Lists]
Advanced

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

Re: Matlab-style empty output/input arguments support


From: Jaroslav Hajek
Subject: Re: Matlab-style empty output/input arguments support
Date: Fri, 29 Jan 2010 21:56:40 +0100

On Fri, Jan 29, 2010 at 8:08 PM, John W. Eaton <address@hidden> wrote:
> On 29-Jan-2010, Jaroslav Hajek wrote:
>
> | yes, I agree. But raising an error about undefined element is a
> | problem. Currently, expressions cannot produce undefined values - if
> | they do, that is an internal error. A multiple assignment in Octave is
> | just an expression producing a cs-list, and it can also appear as an
> | argument list:
> |
> | [c,d] = deal ([a, ~] = deal (1, 2));
> |
> | Allowing undefined values as expression results implies checking every
> | argument list for nulls, and I really dislike that. I think it would
> | be best if the swallowed values were simply substituted by [], i.e. a
> | valid value. It's all really just corner cases anyway, and nothing
> | extra would need to be changed, just octave_lvalue internals.
>
> How about making ~ create a special kind of empty matrix value that
> can only be discarded?  That way
>
>  [c, ~] = deal ([a, ~] = deal (1, 2))
>
> would work, but
>
>  [c, d] = deal ([a, ~] = deal (1, 2))
>
> would fail with an error.  Would it be hard to implement?  Don't we
> already have something similar with [] and zeros(0,0)?
>

I suppose it would. How do you define "only discard"? Internally, deal
is implemented as varargout(1:nargout) = varargin, i.e. the value is
copied at least once. Also, what should happen when you do
[a, ~, b] = deal (1, 2, 3)
without a semicolon - what should be displayed? That is why I wanted a
harmless but otherwise valid value.

Incidentally, is anyone able to check a recent Matlab to find out what
is displayed by the command
[a, ~, b] = deal (1, 2, 3) % without semicolon
?
Is the middle value displayed? If not, then I suppose we really should
simply omit the swallowed variables from the result. That's going to
be easy to implement as well.

regards

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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