> 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
- Re: RFC 57 (v1) Subroutine prototypes and parameters Chaim Frenkel
- Re: RFC 57 (v1) Subroutine prototypes and parameters Piers Cawley
- Re: RFC 57 (v1) Subroutine prototypes and paramet... Piers Cawley
- Re: RFC 57 (v1) Subroutine prototypes and parameters Damian Conway
- Re: RFC 57 (v1) Subroutine prototypes and paramet... Bart Lateur
- Re: RFC 57 (v1) Subroutine prototypes and par... Jacob Davies
- Re: RFC 57 (v1) Subroutine prototypes and... Bart Lateur
- Re: RFC 57 (v1) Subroutine prototypes... Nathan Wiger
- Re: RFC 57 (v1) Subroutine proto... Andy Wardley
- Re: RFC 57 (v1) Subroutine p... Bart Lateur
- Re: RFC 57 (v1) Subroutine p... Andy Wardley
- Re: RFC 57 (v1) Subroutine p... Nathan Wiger
- Re: RFC 57 (v1) Subroutine p... Jonathan Scott Duff
- Re: RFC 57 (v1) Subroutine p... Nathan Wiger
- Re: RFC 57 (v1) Subroutine p... Jonathan Scott Duff
- Re: RFC 57 (v1) Subroutine p... Nathan Wiger
- Re: RFC 57 (v1) Subroutine p... Jonathan Scott Duff
- Re: RFC 57 (v1) Subroutine p... Bart Lateur
- Re: RFC 57 (v1) Subroutine p... Andy Wardley
- Re: RFC 57 (v1) Subroutine p... Bart Lateur
- Re: RFC 57 (v1) Subroutine prototypes and... Jonathan Scott Duff
