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

Re: A possible solution for s?pintf

Thread Previous | Thread Next
March 12, 2005 15:50
Re: A possible solution for s?pintf
Message ID:
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, ...

> I will also remind you of the Scalar C< .as() >  method, which sprintf's 
> it's value.
>    print "$'%03d') $'%15s')";

I like sprintf because with it, I can separate data from presentation.
When I interpolate, I want the things I'm interpolating to be as simple
and short as possible. "Hello, $name" looks natural. "Hello,
$" looks a little less natural. Any .as(ugliness) makes it
impossible to read and leaves you with code-in-text, which as many
templating languages have already shown can very quickly get very ugly.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About