--- In d_lab@yahoogroups.com, "Mariano" <rotoshi@...> wrote:
>
> I was cheking some examples at http://jcc_7.tripod.com/d/tutor/ by
> jccalvarese, and saw that that in the currency example he doesn't
> make use of the parameter's default values (probably not yet
> implemented in D by that time).
>
> The first 3 functions could be expressed with only one:
>
> char[] toStringFromDouble(double i, int decPlaces=2, char[] sep=".")
> {
> int whole;
> .
> .
> .
>
>
> Mariano.
Thanks for bringing this to my attention.
I looked at this example
(http://jcc_7.tripod.com/d/tutor/currency.html) and you're exactly
right that using default
values is a much more elegant means of a solution. In fact, many
aspects of D have changed/improved since I wrote this example. For
instance, toString didn't use to handle doubles (thus the whole
toStringFromDouble function is obsolete and broken).
I'm phasing out that particular website (the pop-ups are really
driving me crazy), so I don't know if I'll update the code there, but
my newer tutorial efforts are hosted by dsource, such as this newly
updated version of the currency example:
http://www.dsource.org/projects/tutorials/wiki/CurrencyExample
(I guess I need to either add links to the new versions of the
examples on my tripod site or remove them completely.)