octave-maintainers
[Top][All Lists]
Advanced

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

Re: functions with 'named' arguments


From: Jaroslav Hajek
Subject: Re: functions with 'named' arguments
Date: Tue, 18 Mar 2008 13:24:20 +0100

>
>  Excuse me ? What am I doing when I use, in R:
>  meanemp(dist="Normale", 4, mean=10)
>  meanemp(mean=10, dist="Normale", 4)
>  ? What is the difference with the suggested
>  hello(closing='bla') ?
>

What I'm trying to explain is that
hello(closing='bla') already *has* a meaning in Octave, and it is
*not* what you have
on mind. In R, this is no problem because the assignment is not "=".
In Fortran and Python, this is no problem because assignment is not an
expression (not sure about Python, but I think so).

It is perfectly legal in Octave (and sometimes useful) to write things like
x = exp (y = -y)
A possible solution would be to implement keyword arguments using
different character than "=", but I think that the standard workaround
using a cell array (of the form {"name", value, "name", value}) is
already good enough.

-- 
RNDr. Jaroslav Hajek
computing expert
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]