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:58
Subject:
Re: A possible solution for s?pintf
Message ID:
20050312235850.GT30120@c4.convolution.nl
Brent 'Dax' Royal-Gordon skribis 2005-03-12 15:51 (-0800):
> Besides, I think "as" will do just fine, especially since you can now
> interpolate method calls as well.  You can even do something like this
> if you want to perform bulk formatting:
>     say join ' ', ($n1, $n2, $n3) >>.as('%d');
> Or, if that's not quite sufficient:
>     say map { .key.as(.value) }
>         $num => '%d',
>         $str => '%s',
>         ...;

I'm really getting the feeling I'm the only one who uses sprintf because
it *separates* and lets you write complex things on one simple line.
That, and I use it a lot in one liners.

Writing complex things as complex things feels weird.

I know there are alternatives, and they're good. I can certainly see how
.as can come in handy. But sprintf (or call it "format", which I do like
better than the unpronounceable "sprintf") as a semi-list operator is
very useful too. I just don't like the amount of typing (with the nested
delimiters: parens and quotes) it requires.


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