help-octave
[Top][All Lists]
Advanced

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

Re: nested functions?


From: Vic Norton
Subject: Re: nested functions?
Date: Thu, 20 Feb 2014 07:59:40 -0500

On Feb 19, 2014, at 12:11 PM, c. <address@hidden> wrote:

> 
> On 19 Feb 2014, at 17:45, fork <address@hidden> wrote:
> 
>> Vic Norton <vic <at> norton.name> writes:
>> 
>>> I would like to be able load a bunch of functions with a
>>> a command like "XXfunctions". 
> 
> We already have such command, it's called "pkg", so why not put 
> your functions into a package so you can just do 
> 
>  pkg load XXfunctions
> 
> and
> 
>  pkg unload XXfunctions
> 
> ?
> c.

I don't use any packages, Carlo, but that may be just what I need. What would 
be a nice, simple package to emulate?

In so far as nested functions I see that my test function

   function outerfunc()
     global printhello = 1;
     nested1();
     function nested1()
       global printhello;
       if printhello
         printf("hello world\n");
       else
         printf("goodbye world\n");
       endif
     endfunction
   endfunction

does works with Octave 3.6.4, albeit with a warning:

   octave> outerfunc
   warning: nested functions are coerced into subfunctions in file
   /Users/vic/Norton/Programming/octave/m/tests/outerfunc.m
   hello world
   octave> global printhello
   octave> printhello = 0;
   octave> outerfunc
   goodbye world
   octave> 

That is encouraging!

Regards,

Vic

reply via email to

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