Re: The Null<> Class

Posted by Dimathematician on
URL: http://quantlib.414.s1.nabble.com/The-Null-Class-tp13063p13065.html

Luigi, I know that you're working on the 1.0 release and it wasn't meant
to go into the next release. I just wanted it to be on some to do list - where
I'd be happy to contribute.

The shortcomings are not bad since it is probably used correctly in the
current library. However, some users might use the particular class- as
a standalone class- in their own applications and might not know about
the mentioned behavior. Also, other contributors might use it without
looking into the details and some errors can occurr, in particular in the
default constructor comparison. This is why I  proposed a temporary fix
until we have something better.

I'm aware of boost::optional and think it could be the way to go. However,
I don't see an easy way to incorporate it in the current Null design. I think
it would have to be used directly such as in:

boost::optional<double> optVar;
QL_REQUIRE(optVar!=NULL,".....");
double var=*optVar;

Anyways, you might be busy with more important stuff. If you need help
to rewrite classes with boost::optional in the future, let me know.



2009/9/23 Luigi Ballabio <[hidden email]>
On Fri, 2009-09-18 at 15:58 +0200, Dima wrote:
>
> I had a closer look at it and would like to propose some changes.

Dima,
       I know, Null<> has a number of shortcomings.  But rather than trying to
patch it, I'd replace it with boost::optional<> instead.

The problem is, we're already late for the 1.0 train.  Over the next
releases, I'll try to replace it in a few places where it doesn't break
backward compatibility.  For the other places, I guess we'll wait for
the next overhaul (2.0, probably in a few years.)  The shortcomings are
not that bad anyway.

Thoughts?
       Luigi


--

Newton's Law of Gravitation:
What goes up must come down. But don't expect it to come down
where you can find it. Murphy's Law applies to Newton's.




------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev