octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #56187] Support local functions at end of scri


From: Andrew Janke
Subject: [Octave-bug-tracker] [bug #56187] Support local functions at end of scripts like Matlab
Date: Tue, 23 Apr 2019 09:10:07 -0400 (EDT)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36

Follow-up Comment #11, bug #56187 (project octave):

> Many uses of script files that contain functions could be handled perfectly
well with Matlab-style local functions that are not globally visible.
Converting Octave scripts to work that way would be fairly easy. 

I agree. I think that would be better programming practice, too: keeping the
scope of definitions only as wide as necessary, and reducing the risk of
collisions in the global namespace.

> If people really want to be able to define globally visible functions in a
script file, then maybe we could provide some way to mark them as such (an
export function or command?).

Maybe we could repurpose the `global` keyword, and use it as a qualifier for
those functions?


global function foo(x)
  [...]
endfunction


Or maybe a global functions block to stick them in, like classdefs have static
method blocks?


global functions
  function foo(x)
    [...]
  endfunction
  function bar(x)
    [...]
  endfunction
endfunctions



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?56187>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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