FAQ: Difference between revisions
Jump to navigation
Jump to search
→Octave extensions: "can not" presumably intended as "cannot"
m (Rename "Octave-Forge" to "Octave Forge" (https://lists.gnu.org/archive/html/octave-maintainers/2018-08/msg00138.html).) |
(→Octave extensions: "can not" presumably intended as "cannot") |
||
(One intermediate revision by one other user not shown) | |||
Line 729: | Line 729: | ||
Octave has a lisp-like {{Codeline|unwind_protect}} block that allows blocks of code that terminate in an error to ensure that the variables that are touched are restored. You can do something similar with try/catch combined with {{Codeline|rethrow (lasterror ())}} in Matlab, however rethrow and lasterror are only available in Octave 2.9.10 and later. MATLAB 2008a also introduced {{Codeline|OnCleanUp}} that is similar to {{Codeline|unwind_protect}}, except that the object created by this function has to be explicitly cleared in order for the cleanup code to run. | Octave has a lisp-like {{Codeline|unwind_protect}} block that allows blocks of code that terminate in an error to ensure that the variables that are touched are restored. You can do something similar with try/catch combined with {{Codeline|rethrow (lasterror ())}} in Matlab, however rethrow and lasterror are only available in Octave 2.9.10 and later. MATLAB 2008a also introduced {{Codeline|OnCleanUp}} that is similar to {{Codeline|unwind_protect}}, except that the object created by this function has to be explicitly cleared in order for the cleanup code to run. | ||
Note that using try/catch combined with {{Codeline|rethrow (lasterror ())}} | Note that using try/catch combined with {{Codeline|rethrow (lasterror ())}} cannot guarantee that global variables will be correctly reset, as it won't catch user interrupts with Ctrl-C. For example | ||
<syntaxhighlight lang="Matlab"> | <syntaxhighlight lang="Matlab"> | ||
Line 926: | Line 926: | ||
demo multinom | demo multinom | ||
=== | ===Powerful assert=== | ||
Function assert have extended input possibilities. | Function assert have extended input possibilities. |