On 2008-Jan-26, at 9:58 am, Larry Wall wrote:
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."

I've always wanted a magic-S (and I don't think the anglocentrism matters, because Perl is already pretty anglocentric -- more so than plural S's, which apply to some other languages anyway).

Rather than extra syntax to specify alternatives, I wonder about having \s work with arrays (which also provides a way to deal with duals, for example):

    say "Received $_ {<ox oxen oxes>}\s" for 1, 2, 77;
    "Received 1 ox"
    "Received 2 oxen"
    "Received 77 oxes"

It might even be sophisticated enough to guess whether it should add "es" or just "s", but anything beyond that probably belongs in a module.

    use Locale::Lingua::EN;
    say "There was\s {3} ox\s";    # There were 3 oxen

    use Locale::Lingua::Romana::Perligata;
    say "{3} bos\s erat\s";        # 3 boves erant

Although calling it "\s" loses its impact in other languages.... But I think the underlying idea to seize on is a way to grab interpolated values so that there's a nice way to do tricks like that. Preferably in a way that doesn't look symmetrical so you can "point" it before or behind.

    say "I've got $bid dollar\s, do I hear {$< + 1}?"

Or using "$<" instead of "\s":
    say "I'm bid $d dollar$< for @this[]$> $o @ox[]$<"

...except that I'm not crazy about calling it "$>". (If that would even work.) But something like that. Perhaps strings should build an array of their interpolations?

    say "$a $b $c, this string contains [EMAIL PROTECTED] interpolations"

(Then again, maybe there's a time to break down and use (s)printf.)


Reply via email to