On Wed, Jul 21, 2004 at 04:37:29PM -0700, Larry Wall wrote:
> No Yes
> -- ---
> @foo @foo[1]
> %bar %bar{"a"} or %bar�a�
> $foo.bar $foo.bar()
> &foo &foo(1)
>
> In this worldview, $foo is an exception only because it doesn't naturally
> have a form that ends with some kind of bracket.
In an ideal universe, here's what I would like to see:
Scalars and things ending in brackets are interpolated. Things
starting with '@' are interpolated if there is an array of that name,
otherwise they are treated as literals.
$foo = 'apple';
%bar = ('a', 1, 'b', 2);
@foo = <<a b c>>;
sub foo { my $param = shift // 7; return $param +2; }
# attached to object $baz which stringifies to '^object baz^'
method bar { return 'quux'; }
print "$foo"; # apple
print "\$foo"; # $foo
print "%bar"; # %bar
print "$baz.bar"; # ^object baz^.bar
print "$baz.bar()"; # quux
print "$baz\.bar()";# ^object baz^. with WARNING: no function bar()...
print "&foo"; # &foo
print "foo()"; # 9
print "&foo()"; # 9
print "&foo(1)"; #
print "@foo[1]"; # a
print "%bar{'a'}"; # 1
print "%bar�a�"; # 1
print "@foo"; # a b c [1]
undef @foo;
print "@foo"; # @foo [2]
[1] Variable @foo exists, so it is interpolated. Separator character
might or might not be space, null string, whatever.
[2] Variable @foo does not exist, so is used as literal value,
possibly with warning. I don't know if there would be a difference
between these:
undef @foo
delete ::{'@foo'} # Perl5 syntax...still correct?
If there is, then probably the latter is required.
--
[EMAIL PROTECTED]