On Tue, Jul 20, 2004 at 06:28:11PM -0400, Aaron Sherman wrote:
: > My preference is "$file\.ext". Clear, light and ascii.
:
: That's fine as far as it goes, but how do you say what, in Perl 5, I
: would use this for:
:
: "${foo}n"
:
: I like the ${} syntax, but I'm a shell guy from my early days... long
: before I touched Perl. If ${} is going to go away, then it seems like
: the best route is one of:
:
: * The pythonish "%sn" % ($foo) sprintf operator, something other
: than % though. Might even be -> with appropriate layers of sugar
: * "$($file)n"
: * "$file\bn" \b is word-break in regexp, so it makes sense to me
: here mnemonically. Could even have "$\b$money\bM is a lot" which
: would force the lone $ to be literal in the same way as
: "\$$money\bM is a lot" would. Kinda fun.
Those are all pretty bletcherous.
Actually, I've been rethinking this whole mess since last week, and
am seriously considering cranking up the Ruby-o-meter here just a tad.
At the moment I'm inclined to say that the *only* interpolators in
double quotes are:
\n, \t etc.
$foo
@foo[$i]
%foo{$k}
{EXPR}
where the last provides a list context to EXPR. So all of these
would require curlies:
{foo()}
[EMAIL PROTECTED]
{%foo}
{$foo.bar}
{Dog.wag}
{.count}
{~localtime}
[EMAIL PROTECTED]
[EMAIL PROTECTED] '.'}
{$x.as "%10.5d"}
Note that this not only fixes the Perl 6 "% in sprintf" issue, but
also the Perl 5 "@ in email address" issue. It also generalizes the
notion that curlies (almost) always indicate a closure everywhere.
On the other hand, it undoes my stated A12 policy that $x.foo can be
used anywhere $foo can. On the gripping hand, it enables "{.foo}"
where we would have had a lot of "$_.foo", and I think that's an
improvement in readability, at least for people who believe in topics.
Larry