[Vala] Assisted printf format



Hello,

Actually, when I want use a prinf I need remember the data type format string; but vala can do it automatically

I propose create another data type in the format string: ?, like i, g u, li, etc. Example: %?, %-10?

When use '?' vala can translate this for the real format string, indicate in CCode attribute

Example:
void main () {
    string a = "foo";
    double b = 123.45;
    long c = 678;
    uint d = 9;
    stdout.printf ("Hello World: %-10?%g %?%?\n", a, b, c, d);
}

Vala translate the printf string to "Hello World: %-10s%g %li%u\n"

The '?' indicate to vala that must use assisted prinf format

The assisted prinf format can:
- use a format string indicate in CCode attribute (ideal for int, uint, string, etc.)
- get a field value indicate in CCode attribute (ideal for StringBuilder, for get str field value)
- call a to string method o another indicate in CCode attribute (ideal for general propose and for bool)

I'm working for do it.

I want to know what their opinions about that

--
Juan Luis Paz


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]