[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 10:11:20 +0100 |
On Thu, Jan 28, 2010 at 10:14 AM, Olaf Till <address@hidden> wrote:
> On Wed, Jan 27, 2010 at 01:03:19PM +0100, Jaroslav Hajek wrote:
>> ...
>> So we can now do:
>>
>> octave:1> [~, y] = deal (1, 2);
>> octave:2> who
>> Variables in the current scope:
>>
>> ans y
>>
>> octave:3> y
>> y = 2
>> octave:4> f = @(~, y) disp (y)
>> f =
>>
>> @(~, y) disp (y)
>>
>> octave:5> f(1, 2)
>> 2
>> octave:8> function a = g (x, ~, y = 1), a = x+y; endfunction
>> octave:9> g(1,2,3)
>> ans = 4
>
> This looks very nice to me. Just my 2 cents from the users point of
> view:
>
>> Should
>> [c,d] = [a,~] = myfun (...)
>> simply raise an error?
>
> An error (element number 2 undefined in return list) would seem
> logical to me. But I think one should be able to do something like
>
> [d, ~, f] = [a, ~, c] = myfun (...)
>
> Olaf
>
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.
--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
Re: Matlab-style empty output/input arguments support,
Jaroslav Hajek <=
- Re: Matlab-style empty output/input arguments support, John W. Eaton, 2010/01/29
- Re: Matlab-style empty output/input arguments support, Jaroslav Hajek, 2010/01/29
- Re: Matlab-style empty output/input arguments support, Søren Hauberg, 2010/01/29
- Re: Matlab-style empty output/input arguments support, Jaroslav Hajek, 2010/01/29
- Re: Matlab-style empty output/input arguments support, John W. Eaton, 2010/01/29
Re: Matlab-style empty output/input arguments support, Michael D Godfrey, 2010/01/29
Re: Matlab-style empty output/input arguments support, Michael D Godfrey, 2010/01/29
Re: Matlab-style empty output/input arguments support, Jaroslav Hajek, 2010/01/30