|
Boost : |
From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-01-24 10:14:47
----- Original Message -----
From: "Stewart, Robert" <stewart_at_[hidden]>
> At the risk of beating a dead (or very sick) horse, let me show the same
> example in the [] notation:
>
> format("[12]345") ["#1"]["#2"]["#3"]["#4"]["#5"]["#6"]["#7"]
> ["#8"]["#9"]["#10"]["#11"]["$$"] => $$345
>
> or:
>
> format("[12]345") ["#1"] ["#2"] ["#3"] ["#4"] ["#5"] ["#6"] ["#7"]
> ["#8"] ["#9"] ["#10"] ["#11"] ["$$"] => $$345
>
> in case the added whitespace looks better to someone.
>
> Now, add a couple of manipulators in there:
>
> format("%12345") % "#1" % "#2" % "#3" % hex % "#4" % "#5" % "#6" %
"#7"
> % "#8" % "#9" % dec % "#10" % "#11" % "$$"
>
> format("[12]345") ["#1"]["#2"]["#3"](hex)["#4"]["#5"]["#6"]["#7"]
> ["#8"]["#9"](dec)["#10"]["#11"]["$$"]
I understand the strong technical arguments for this syntax, but I think
this library is unique in the sense that comfort and familiarity are going
to count a lot more here than they will in other libs. 'C', lisp, and
Python** programmers are already used to the idea that "%" has something to
do with argument substitution. I think it's going to be hard to get people
to accept the idea of delivering arguments via operator[]. It certainly
isn't easy for me.
BTW, I think it's rare that the arguments to format will be string literals
(might as well put them in the format string), so choosing a more realistic
example:
format("%12345") % a1 % a2 % a3 % a4 ... % dollar_dollar;
I don't think this needs [] or << to be readable.
furthermore, I have always been displeased with the sticky nature of the
manipulators, and would much rather see:
... % a3 % hex(a4) % ...
in most cases, which would help to distinguish them.
-Dave
**who else? MatLab, for one - there must be countless others
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk