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

Re: A possible solution for s?pintf

Thread Previous | Thread Next
From:
Juerd
Date:
March 12, 2005 15:50
Subject:
Re: A possible solution for s?pintf
Message ID:
20050312235040.GS30120@c4.convolution.nl
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 "$foo.as('%03d') $bar.as('%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,
$person.name" 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.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Thread Previous | Thread Next


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