Re: [QuantLib-svn] SF.net SVN: quantlib: [13872] trunk/QuantLib/ql/cashflows

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [QuantLib-svn] SF.net SVN: quantlib: [13872] trunk/QuantLib/ql/cashflows

Luigi Ballabio

On Dec 22, 2007, at 5:49 PM, [hidden email] wrote:

> Revision: 13872
>          
> http://quantlib.svn.sourceforge.net/quantlib/?rev=13872&view=rev
> Author:   nando
> Date:     2007-12-22 08:49:11 -0800 (Sat, 22 Dec 2007)
>
> Log Message:
> -----------
> switched signatures to Natural instead of Integer and const Date&
> instead of Date

Nando,
        in the function you modified, the Date was passed by value on purpose.
That way, it could be modified:

>      Real CashFlows::npv(const Leg& cashflows,
>                          const InterestRate& irr,
> -                        Date settlementDate) {
> -        if (settlementDate == Date())
> -            settlementDate = Settings::instance().evaluationDate();

whereas if you pass it by const reference, you have to introduce an
additional object:

> +        Date refDate = settlDate;
> +        if (refDate == Date())
> +            refDate = Settings::instance().evaluationDate();

Also, why "settlDate"? Looks less readable to me.

Merry Christmas,
        Luigi


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev
Reply | Threaded
Open this post in threaded view
|

Re: [QuantLib-svn] SF.net SVN: quantlib: [13872] trunk/QuantLib/ql/cashflows

Ferdinando M. Ametrano-3
On Dec 22, 2007 10:18 PM, Luigi Ballabio <[hidden email]> wrote:
>         in the function you modified, the Date was passed by value on purpose.
> That way, it could be modified [...]
> whereas if you pass it by const reference, you have to introduce an
> additional object:
you're right. I can change it back, or keep the const reference and
introduce the additional object only if the provided Date is invalid
(at the cost of duplicationg 2 lines of code). Whatever you prefer...
just let me know.

> Also, why "settlDate"? Looks less readable to me.
In the hpp files it's settlementDate, anyway I'll switch it back to
settlementDate in the cpp too.

thank you

ciao -- Nando

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev