octave-maintainers
[Top][All Lists]
Advanced

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

Re: Change/add symbol for omitted default arguments?


From: Jaroslav Hajek
Subject: Re: Change/add symbol for omitted default arguments?
Date: Thu, 29 Jul 2010 12:54:55 +0200

On Thu, Jul 29, 2010 at 11:33 AM, Jaroslav Hajek <address@hidden> wrote:
> On Thu, Jul 29, 2010 at 3:29 AM, Judd Storrs <address@hidden> wrote:
>> Octave allows default values for function arguments such as
>> function [a,b,c] = myfunc(d,e=3,f)
>>     ....
>> endfunction
>> When calling the function the default parameter can be used by entering the
>> ":" symbol.
>> [a,b,c] = myfunc(3,:,5)
>> http://www.network-theory.co.uk/docs/octave3/octave_104.html
>> Recent versions of octave (and Matlab apparently) have adopted ~ to mark
>> ignored output parameters. Given this change I think it would be
>> congruous for the octave language to also adopt the ~ for omitted default
>> input arguments.
>> [a,~,b] = myfunc(3,~,5)
>> An alternative would be to allow : to also mark ignored output parameters.
>> [a,:,b] = myfunc(3,:,5)
>> "~" carries the meaning of "not" in octave and seems semantically more
>> correct than ":" which carries the meaning "all".
>>
>> --judd
>> [According to comments on StackOverflow Matlab additionally uses ~ inside
>> function declarations to mark positional parameters that are ignored by the
>> function definition.
>
> Octave supports this as well.
>
>> I'm not entirely sure what this achieves due to the
>> copy-on-write parameter passing except that perhaps Matlab may be able to
>> skip evaluating the arguments. I don't think that particular optimization
>> can play nice with octave's evaluation model which allows things like
>> myfunc(3,f=myfunc2(g=5),5) with the second parameter marked ~ in the
>> function definition]
>>
>
> I wondered the same thing. It seems just syntactic sugar to cleanly
> mark a placeholder input argument.
>
> regards
>

I should have added that although I see the point, I'm quite happy
with the syntax as is so I don't consider this change to be worth the
effort. ~ is Matlab compatible, : as an omitted input argument is
Octave's specialty. Maybe others can share more opinions.

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]