Hi,
This is already handled in Perl 5 - which I guess will have
an influence on Perl 6. I doubt Larry is going to force
everyone to quote the hash subscripts (are you Larry? :)
Let a newish (6 < now < 12 months) non professional
(unemployed student ;) Perl programmer, like myself, look
at how he'd expect things to be handled - and what actually
happens.
Hence, I'm going through this twice... once BEFORE testing
my expectations in Perl, and once AFTER.
> $foo{shift} vs. $foo{"shift"}
Hmm... I think 'shift' would be taken as the key, not the
function in both cases.
ANS: I was correct
> $foo{bar} vs. sub bar() { ... } $foo{bar}
As previous.
> vs. $foo{+bar}
I think the + would cause it to fail... since it looks a
little like it is part of a sum.
ANS:
The + forces it to an EXPR, meaning that bar is treated as
a function call. However - this action still makes sense
to me, since + is used to force scalar context in some
places.
> vs. $foo{bar()}
Now, this would call bar().
ANS: I was correct.
> vs. $foo{"+bar"}
Easy, it's a key.
> vs. $foo{"bar()"}
Easy, it's a key.
> and they never cause any problems?
Not usually :)
The rules actually do what I (think) I mean, in almost all
cases. Only perlTk causes any problems since the named
arguments are prefixed with minus symbols. In this
instance they need quoting.
Jonathan Paton
__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com