help-octave
[Top][All Lists]
Advanced

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

Re: nested functions?


From: Mike Miller
Subject: Re: nested functions?
Date: Tue, 18 Feb 2014 16:24:50 -0500

On Tue, Feb 18, 2014 at 14:29:55 -0500, Vic Norton wrote:
> The file "outerfunc.m" consisting of
>
>    1;
>    function outerfunc()
>      global printhello = 1;
>      nested1();
>      function nested1()
>        global printhello;
>        if printhello
>          printf("hello world\n");
>        else
>          printf("goodbye world\n");
>        endif
>      endfunction
>    endfunction
>
> produces the "nested functions not implemented in this context" error
> message in Octave 3.8.0. However, if you comment out the "1;" line, it
> works fine:

Right, that's what I meant by converting it to a function file, an
m-file that defines a callable function versus a script file. If the
first line (aside from comments) is a function definition, it is
parsed as a function file, otherwise it is parsed as a script file.

> It would be interesting to see how this file works in Matlab. I don't
> particularly like the Octave behavior.

Agree, if someone can test this in Matlab and post the results that
would be helpful. You might go ahead and report this on the Octave bug
tracker anyway.

-- 
mike


reply via email to

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