help-octave
[Top][All Lists]
Advanced

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

Re: Scripts within functions


From: José Vallet
Subject: Re: Scripts within functions
Date: Thu, 13 Oct 2011 09:35:43 +0300
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110922 Thunderbird/3.1.15

On 10/10/2011 05:37 PM, John W. Eaton wrote:
On 10-Oct-2011, José Vallet wrote:

| Is it possible to define and use scripts within functions?
|

Currently in Octave, the script parts would have to go in separate
files and you can't pass any arguments to them.

In Matlab, nested functions work the way you want, but most of the
Octave developers think that is not good programming practice since
Matlab also lacks any sort of local variable declaration, so it makes
modifying code written this way risky.  If your function has many
variables, then it becomes difficult to know whether a nested function
is supposed to be modifying variables in the calling function's scope,
and it is easy to accidentally make changes which have unintended
consequences by changing values in the parent function.


Yes, I understand the risks, thanks for the clarifications. I just wanted a quick way to clean my code by shrinking non essential parts into a single line.

Thanks to all for your comments.

Jose


reply via email to

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