> And that's just too much punctuation for too little value.
>
> How special purpose is "with"? Do people envision using it *only* on
> hashes? (I did until this email) If so, I like Damian's version best:
>
> http://www.mail-archive.com/perl6-language@perl.org/msg02649.html
Unfortunately, as has been subsequently pointed out, that cunning plan is
fatally flawed, if you rely on higher order functions to keep the syntax
clean.
So I'm back to proposing that
with (%hash) {
...
print $_{name};
print @_{qw(name rank snum};
print keys %_;
...
}
simply be sugar for:
{ local %_=%hash;
do {
...
print $_{name};
print @_{qw(name rank snum};
print keys %_;
...
}
}
Oh, and %_ could become the default argument to the various hash-related
builtins, allowing for:
with (%hash) {
...
print keys;
...
}
This is no more typing than:
with (%hash) {
...
print ->{name};
print ->{qw(name rank snum};
print keys ??????;
...
And it's entirely consistent with existing Perl
(it doesn't even add a new punctuation variable).
I'd also suggest that C<with> also be allowed to take
a reference to a hash and alias %_ to the hash.
That would simplify handling nested data structures:
with ($loholoh->[1]{to}[4]{see}) {
...
$_{field1} = $data1;
$_{field2} = $data2;
$_{field3} = $data3;
...
}
Damian
PS: Just *love* Larry's "yadda yadda yadda" operator!