"D" annoyances
Ty Tower
tytower at hotmail.com.au
Sat Mar 15 14:53:04 PDT 2008
Ty Tower Wrote:
> Ty Tower Wrote:
>
> > Take them as things to be fixed or deny their existence
> >
> > Either way I will post here the stupid things I find as I go through bits and pieces .
> > The best critic is the most schooled in the subject
>
>
> Another
> The output does not recognise "C" nor "alignment" ?
> Your lookers should not have to go delving to find out why, it needs to just work.
>
> [tytower at linuxbox text]$ formatspec
> I have {unknown format 'C'} in cash.
> Avogadro's number is 6.02e+23.
> Avogadro's number (with alignment) is 6.02e+23.
>
>
> This is the example program which also appears in the tango book
> /**
>
> Example showing how to use format specifier components in a format string's
> argument.
>
> Put into public domain by Lars Ivar Igesund
>
> */
>
> import tango.io.Stdout;
>
> void main(){
> double avogadros = 6.0221415e23;
> Stdout.formatln("I have {0:C} in cash.", 100);
> Stdout.formatln("Avogadro's number is {0:E}.", avogadros);
> Stdout.formatln("Avogadro's number (with alignment) is {0,4:E}.", avogadros);
> }
>
The debug section in the library file gives a debug function which I extracted ,changed and ran . It works OK
import tango.io.Console;
import tango.text.convert.Layout;
void main ()
{
auto layout = new Layout!(char);
layout.sprint (new char[3], "hi");
Cout (layout ("{:d2}", 56)).newline;
Cout (layout ("{:f4}", 0.001)).newline;
Cout (layout ("{:f8}", 3.14159)).newline;
Cout (layout ("{:e20}", 0.001)).newline;
Cout (layout ("{:e4}", 0.0000001)).newline;
Cout (layout ("ptr:{}", &layout)).newline;
Cout (layout ("{:C}}", 4.456789)).newline;
Cout (layout ("{:c}}", 4.456789)).newline;
struct S
{
char[] toString () {return "foo";}
}
S s;
Cout (layout ("struct: {}", s)).newline;
}
/*Output of this is OK -I added ":C" liness to the tango library file it wasn't there
[tytower at linuxbox Desktop]$ TestLayout
56
0.0010
3.14159000
0.10000000000000000000e-02
0.1000e-06
ptr:bfc6a008
4.46}
4.46}
struct: foo
More information about the Digitalmars-d
mailing list