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: Judd Storrs
Subject: Re: Matlab-style empty output/input arguments support
Date: Thu, 28 Jan 2010 20:57:37 -0500

On Thu, Jan 28, 2010 at 4:14 AM, Olaf Till <address@hidden> wrote:
> 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 (...)

Some additional ideas:


1) ~ vanishes whenever it appears on the rhs of an expression (I think
this is what octave calls a cs-list?). Then

[c,d] = [a,~] = myfun (...)

would raise an error because it would be evaluated as

[a,~] = myfun (...)
[c,d] = deal(a)   <<< ERROR

but this

[d, f] = [a, ~, c] = myfun (...)

would succeed because it is equivalent to

[a, ~, c] = myfun(...)
[d, f] = deal(a,c)

I don't know if deal shares code with assignment; but, maybe all that
needs to happen is that deal() learns to skip over ~ ?


2) Another option could be that ~ evaluates to an empty matrix in an
expression. The downside is that

[c,d] = [a,~] = myfun (...)

would be legal and equivalent to

[a,~] = myfun(...)
c = a
d = []

and

[d, ~, f] = [a, ~, c] = myfun (...)

is evaluated as

[a, ~, c] = myfun(...)
d = a
f = c

Option 2 seems more disruptive, because previously a solo ~ on the
right hand side would have been a parse error i.e. typo.

I think I prefer option 1.


--judd


reply via email to

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