develooper Front page | perl.perl6.language | Postings from March 2005

Re: A possible solution for s?pintf

Thread Previous
From:
Rod Adams
Date:
March 12, 2005 16:25
Subject:
Re: A possible solution for s?pintf
Message ID:
4233885F.5000702@rodadams.net
Juerd wrote:

>Rod Adams skribis 2005-03-12 17:41 (-0600):
>  
>
>>Why not just rename C< sprintf > to C< format > and ditch printf and sayf?
>>    
>>
>
>Because format is almost as much typing as sprintf, and in many
>circumstances needs both parens and quotes:
>
>    format("%03d %15s", $foo, $bar), $baz, ...
>
>compared to
>
>    f/%03d %15s/$foo, $bar/, $baz, ...
>  
>
Well, I use s?printf extensively in my code, and IMO, it's about the 
right level of huffmanization. C< .as() > seems to nicely take care of 
the cases where C< sprintf > is too heavy.

Also, on second thought, don't ditch C< printf >. I use it too much. But 
I don't see a need for C< sayf >. If you're going through the effort of 
supplying a pattern, you can type the "\n".


What's always bothered me about s?printf was that it was doing something 
roughly similar to RE's: describing a string pattern, but used a 
completely different syntax. Admittedly, it's working in the other 
direction, generation, not parsing, but they still seem terribly far 
apart at that.  But I haven't thought enough about it to offer a 
proposal on the subject.

-- Rod Adams

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About