Larry Wall wrote: > Last night I got a message entitled: "yum: 1 Updates Available". > Of course, that's probably just a Python programmer giving up on doing > the right thing, but we see this sort of bletcherousness all the time. > > After a recent exchange on PerlMonks about join, I've been thinking > about the problem of pluralization in interpolated strings, where we > get things like: > > say "Received $m message{ 1==$m ?? '' !! 's' }." > > My first thought is that this is such a common idiom that we ought > to have some syntactic sugar for it: > > say "Received $m message\s." > > which reads nicely enough since the usual case is plural. > Basically, \s would be smart enough to magically know somehow whether > the last interpolation was 1 or not. It would be particular nice when > the interpolation is a closure: > > say "Received {calculate_number_of_messages()} message\s."
I think the most general solution is a nice quoting construct. So if you say say qq:l10n(en)"Received $m message\s"; the quote handler in l10n:en (or whatever) receives a list of pairs of strings and variables to interpolate, ['$m' => $m, '\s' => undef]. It can then decide what to do with it. Wait, that smells like macros, which are already specced - so never mind ;-) Moritz -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/
signature.asc
Description: OpenPGP digital signature