Pavel,
On Fri, Jul 11, 2014 at 7:30 PM, Pavel Roskin <
plro...@gmail.com> wrote:
> Misha,
>
> I think formatting should be done by the object. Objects could have
> methods for printing with optional arguments.
>
> class double {
> string to_string(width = 100, precision = 15);
> }
>
> By the way, I like infinity as in in Scheme. The default width could
> be positive infinity (even if it's reduced to the maximal integer).
>
> If we want expressions in parentheses, this should work:
>
> println("val = \(val.to_string(precision = 5))");
>
> Those would be equivalent:
>
> println("val = \(val)");
> println("val = \(val.to_string())");
>
> Most objects are only printed in one way. Printing floating point
> numbers is rare. So I don't worry much about having to use
> to_string() explicitly in those rare cases.
Yes, I think this addresses the most common use case.
In FORTRAN one formats and prints floating numbers a lot. Today on the
web, not so much. :)
=Misha.
>
> Pavel