octave-maintainers
[Top][All Lists]
Advanced

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

Re: Default arguments


From: Sean O'Rourke
Subject: Re: Default arguments
Date: Fri, 15 Dec 2006 06:54:00 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (darwin)

"John W. Eaton" <address@hidden> writes:
> Wouldn't it be better to be able to write
>
>   function foo (arg = 42)
>     ...
>
> instead?

It would also be better to be able to call foo like

    foo(arg = 42)

i.e. to have keyword arguments.  I've often found the following
idiom useful

    function blah(x, varargin)
        o = struct({ 'default', 1, 'values', 2, 'here', 3,
                     varargin{:} }{:});

    ...
    blah(x, 'here', 4);

but a bit of syntactic sugar around that would help.  If others
feel this is a good idea, I can probably implement it based on
John Eaton previous patch.

/s



reply via email to

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