Boost logo

Boost :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2001-12-19 14:25:38


> This still does not address the ambiguity point. The elegance
> of printf formats is that it has both a starting char and endin

"%1000 bla bla" means argument number 1000, you have to supply the 999
other arguments even if not printed.

The argument number stops at the first non-digit char.

I know it is not enough, if you want to print a digit right after an
argument.
I thought about "%1% %2%" too. But it's longer. And if I do a
'short-style notation', I aim for the quickest syntax possible.
Right now, to disambiguate these case you can use a printf directive.
Well, it would require users to use printf directives even if they don't
want to,
so I might add a directive specifically for this :
"%1%z00000"
or any other "%c" marker with c being a non-digit char, and not 'p'.
(already used to insert a printf directive)

> Also if you are going to do a simple format class why %1 instead of $1
> which is more familiar to shell coders. Then you could resolve
> the ambiguity with ${10} (Okay, maybe too much perl programming in recent
> times.

Why not.
personnally I prefer
cout << format("%1 \n") % x;
to
cout << format("$1 \n") % x;
But it's personnl taste.

the bracket system works as well for % or $ :
format("%{5}000 \n") % x;
doesn't look too different from ${5}000. (yes, ${5} is very exactly the
way shell coders do it. but shell coding is .. shell coding :-)

so using % or $ is really a matter of personnal taste.

using brackets when needing to disambiguate looks nicer than using a
marker (like %z), so I might just do that.

As for %1 vs $1.. it's cosmetic. I guess only a vote could settle that.
But anyway, I can change that in 2 seconds, so the debate should not
concentrate on this issue.

regards,

-- 
Samuel

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk