help-octave
[Top][All Lists]
Advanced

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

Re: named arguments


From: John W. Eaton
Subject: Re: named arguments
Date: Fri, 16 Mar 2012 10:08:32 -0400

On 16-Mar-2012, Jordi Gutiérrez Hermoso wrote:

| 2012/3/16 Jordi Gutiérrez Hermoso <address@hidden>:
| > On 16 March 2012 07:53, Olaf Till <address@hidden> wrote:
| >> I'm not aware of Octave supporting named arguments. There was once a
| >> suggestion to support named arguments, but it has been disapproved
| >> because of the risk of future incompatibilities with Matlab.
| >
| > I wish we could fix this. Named arguments are a huge convenience. Can
| > you think of something better than this?
| >
| >    http://abandonmatlab.wordpress.com/2009/07/31/no-named-arguments/
| 
| Oh, and here is my idea:
| 
| Introduce some sort of syntax in function declarations (maybe
| something like Python's traditional **kwarg?) that will give you a
| struct with the named arguments, so perhaps something like
| 
|     function out = foo(bar, baz, **kwarg)
|         ## ...
|     endfunction
| 
| Now if you call the function like this:
| 
|     foo(1,2 "oh", 2, "hai", rand(3), "there", "lol");

You can already do keyword-value pairs, so I don't see the point of
introducing new syntax in the function declaration.

jwe


reply via email to

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