help-octave
[Top][All Lists]
Advanced

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

scoping blocks in octave code?


From: fork
Subject: scoping blocks in octave code?
Date: Thu, 17 Nov 2011 19:57:47 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Hi all,

Is there a way to limit the scope of variables in a stretch of code?  This can
be useful with temporary index variables in for-loops, but it can be nice in
many other contexts (though one should probably be more aggressively putting
stuff into functions if this kind of housekeeping becomes necessary).

I don't think this is possible, but I was happily surprised with the support for
closures and subfunctions so I thought I would ask....

I *think* in newer versions of C, if you declare a variable inside a block, that
variable goes out of scope at the end of the block. Schematically:

begin
    for myind = 1:10
         blah += myind
    endfor
endbegin

## now myind would be gone


Tx



reply via email to

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