> The difference is that inside the sub, you don't access the hash values
> using prefixes for the keys, either. With (automatically created)
> lexical variables, you do.

True.

I wonder if we could change '=>' to always quote the lhs, even if 
prefixed by '$', '@', or '%'  (maybe we should only enable this 
behaviour inside parameter lists?)  That would allow us to do this.

   sub foo ($one, $two) {
       ...
   }

   foo($one => 1, $two => 2);

When we parse the parameter list, anything key with a leading funny 
character is assumed to be a named parameter.  Anything without 
is assumed to be a regular quoted word.  

   sub bar ($one, %two) {
       ...
   }

   bar($one => 1, x => 20, y => 30, z => 40);

# or 
   bar($one => 1, %two => (x => 20, y => 30, z => 40));

# or (with Highlander Variables)
   bar($one => 1, $two => { x => 20, y => 30, z => 40 });

Admittedly it's not very visually distinct in the first case but this 
example is probably the worst case scenario.

And if you really wanted to interpolate a variable to get a hash key 
then you would use ',' instead of '=>'. 

   my $key = 'y';

   bar($one => 1, x => 20, $key, 30, z => 40);
                              ---

Thoughts?


A

Reply via email to