octave-maintainers
[Top][All Lists]
Advanced

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

Re: Random questions


From: Júlio Hoffimann
Subject: Re: Random questions
Date: Thu, 20 Dec 2012 17:32:50 -0300

Hi John,

There are two things that this function returns, the stream and the
number.  C++ functions can only return one value.  It makes more sense
to return the stream directly, so the other is returned by reference
in the argument list.


If you inspect the rest of the code, you'll see single_num() is actually never called
according to it's prototype. I'll produce a patch, unless this is not desired for some
other reason.

In fact, i would replace the entire single_num() function by either a try/catch block with boost::lexical_cast<double> which is more robust and faster (see http://www.boost.org/doc/libs/1_52_0/doc/html/boost_lexical_cast/performance.html for performance considerations) or be conservative and use std::strtod() (http://en.cppreference.com/w/cpp/string/byte/strtof)
 
They are static because they are only needed to help implement other
functions in the file, so there is no need to have access to them
outside the scope of the single file where they are defined.

I see all free functions defined as static, maybe my code exploration was biased. :)

Best,
Júlio.

reply via email to

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