[Top][All Lists]

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

[Octave-patch-tracker] [patch #8033] Implement missing function evalc()

From: Rik
Subject: [Octave-patch-tracker] [patch #8033] Implement missing function evalc()
Date: Fri, 15 Jan 2016 17:34:08 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Update of patch #8033 (project octave):

                  Status:             In Progress => Done                   
             Open/Closed:                    Open => Closed                 


Follow-up Comment #18:

Finally!  This function is complete and checked in here
(http://hg.savannah.gnu.org/hgweb/octave/rev/5ed379c8decd).  I made a few
changes which I'll document.

1) I added evalc to the list of new functions in the NEWS file.

2) Dropped const from nargin declaration.

-  const int nargin = args.length ();
+  int nargin = args.length ();

While it is true that nargin is const, it is almost never necessary to specify
it.  "nargin" is a local variable and the compiler can determine whether the
value is changed (it isn't) and can make appropriate optimizations.

3) Replace NULL with 0 for pointers

-  if (eval_exception != NULL)
+  if (eval_exception)

NULL is a macro which can expand to different values in the C language.  In
C++, Bjarne Stroustrup himself recommends just using 0.  Eventually when
Octave supports C++ 2011 the nullptr keyword could be used.  See this
discussion on StackOverflow:

4) Add semicolons to regular assert statements versus specialized %!assert.

 %! [s, y] = evalc ("1");
-%! assert (s, "")
-%! assert (y, 1)
+%! assert (s, "");
+%! assert (y, 1);

The Octave convention is that '%!assert' does not end in a semicolon whereas
the ordinary function call 'assert' does end with a semicolon because it is
the same as any other piece of Octave code.

5) Use "local" option to warning to simplify code

The "local" option automatically restores a configuration variable or setting
when the scope of the function disappears.  It is a convenient way to
temporarily modify an option without having to write a long unwind_protect

-%! quiet = warning ("query", "quiet");
-%! warning ("off", "quiet")
-%! unwind_protect
-%!   assert (evalc ("warning ('foo')"), "warning: foo\n")
-%! unwind_protect_cleanup
-%!   warning (quiet.state, quiet.identifier);
-%! end_unwind_protect
+%! warning ("off", "quiet", "local");
+%! assert (evalc ("warning ('foo')"), "warning: foo\n");


Reply to this item at:


  Message sent via/by Savannah

reply via email to

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