help-octave
[Top][All Lists]
Advanced

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

Re: Opinions on Matlab compatibility, Octave development


From: Judd Storrs
Subject: Re: Opinions on Matlab compatibility, Octave development
Date: Fri, 4 Jun 2010 11:01:06 -0400

On Fri, Jun 4, 2010 at 9:44 AM, CdeMills <address@hidden> wrote:
>> forkandwait wrote:
>> 1.  Named parameters a la Python like  "z = f(x=3, y=[1 2 3])"
>
> I launched this kind of discussion months ago. The replies where : "try to
> implement it". I looked into the parser code, but, quite frankly, I didn't
> feel at ease modifying it.

I think the main objection is that octave currently evaluates

func(a=100,b=300)

as

a=100;
b=300;
func(a,b)

Octave's current behavior is fairly generic and supports use outside
function calls such as:

b = (a=(a+56))/7

expanding as

a=a+57
b=a/7

This arguably a good thing because it allows more compact expressions.
Personally I don't use that style but some people like it. I think it
would be confusing to modify parsing rules for = inside parameter
lists.

On the other hand I also really jones for named parameters because it
would make it so much easier to port IDL code to octave. (Probably R
code as well)

My current opinion is that octave could adopt a new symbol for
assignments like this. An obvious choice (to me at least) is ":=".
Then we could have access to named parameters via

func(a:=100, b:=300)

Because the := would be a new token (and I can't think if any cases
this sequence of characters could ever show up in valid octave or
Matlab code) it should be more straightforward to implement than
context-dependent parsing of "=".


--judd



reply via email to

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