octave-maintainers
[Top][All Lists]
Advanced

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

Re: help needed to verify expected behavior for scripts and nested funct


From: Markus Mützel
Subject: Re: help needed to verify expected behavior for scripts and nested functions
Date: Wed, 8 Apr 2020 17:18:08 +0200

Am 08. April 2020 um 15:33 Uhr schrieb "John W. Eaton":
> Yes, thanks.

Glad, I could help.

> So, scripts are a bit weird.  They execute in the workspace of the
> function where they are called so that they have access to the variables
> there but they don't see the nested functions that belong to the
> function that corresponds to that workspace?  OK.  That's actually
> consistent with how Octave behaves now in version 6, since the big call
> stack refactoring.  But previously in Octave, the script would see the
> nested function.  It's not really important, but I wonder whether the
> behavior also changed in Matlab?  Or has it always been this way since
> nested functions were introduced?  These details don't seem to be
> clearly defined in any Matlab docs that I can find online.

Maybe this resource can help understanding their precedence order handling:
https://de.mathworks.com/help/matlab/matlab_prog/function-precedence-order.html

In particular "3. Nested functions within the current function". Looks like the 
script is *not* "within the current function".
But what that really means is not entirely clear to me either from reading just 
the documentation.

Not sure if or when that changed. I run fcn1 in R2016a and R2012a, and they 
both failed with the same error in script1 (like R2019b).

> Octave doesn't have local functions for scripts that behave the same way
> as in Matlab, so the fcn2 and script2 is info for the future.  It's good
> to know that the local function is found in that case.
>
> jwe
>



reply via email to

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