On Mon, Jun 16, 2003 at 11:37:06AM -0700, Michael Lazzaro wrote:
> [...]
> But there is broad support for the idea that the somewhat elderly 
> printf syntax is a PITA, and that printf, in general, should be 
> completely unnecessary since we already *have* interpolated strings, 
> fer pete's sake.

A PITA, yes, but a darned powerful *and concise* PITA.


>   Is it possible that
> 
>     "The value of x is <expr but formatted(...)>"
> 
> is in fact a cleaner, more elegant syntax than:

Quite honestly, I'd like to do better.  One of the things that makes
regexen so powerful is their concision; they pack a tremendous amount
of meaning into every character and yet, for the most part, they
aren't that hard to understand.  I'd like to see the same for output
rules.  The vast majority of output rules will probably be on the
order of: "make this an integer and left-pad with 0s to make sure
there are at least 2 digits".  I'd much rather write:

     "The value of x is \F02d$($x)"

than

     "The value of x is $($x as integer but
     formatted(<two-digits-left-pad-0>)" 


> Or, if we have "output rules" just like we have "input rules", could 
> something quite complex be expressed simply as:
> 
>     "You have <$x as MoneyFormat>"

I like this better; a good compromise between concision and
readability (although the later poster's suggestion of
'MoneyFormat($x)' was even better, IMO).  

You still need to define MoneyFormat somewhere, however; I hope that
you will be able to do that with nice concise formatting codes.


--Dks

Reply via email to