help-octave
[Top][All Lists]
Advanced

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

Re: A suggestion about the code


From: Jordi Gutiérrez Hermoso
Subject: Re: A suggestion about the code
Date: Sat, 23 May 2015 10:47:04 -0400

On Fri, 2015-05-22 at 19:44 -0400, Nicholas Jankowski wrote:
> I also found that for no discernable reason, octave's implementation of
> this seems not perfect (surely the errors weren't my fault :) ). I've had
> scripts unable to find functions for no good reason until closing and
> restarting Octave, at which point it would be fine.

The explanation is as follows: Octave allows files to be parsed in
script mode or function mode. Function files are those whose first
statement is "function". A script file is one whose first statement is
anything other than "function".

Script files have "side effects", so to speak. One of the side effects
of a script file is to define a new function. Thus if you define a
function in script mode, then the script has to be evaluated each time
for the changes to that function to take effect.

For a function defined in function mode, Octave always checks to see
if the file has changed without you needing to evaluate it.

This is also explained in the manual,

   https://www.gnu.org/software/octave/doc/interpreter/Script-Files.html

HTH,
- Jordi G. H.





reply via email to

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