John Porter writes:
> So?  Perl's not like that.  Perl is diagonal.  And this is just
> another corner being cut.

Cut away enough corners, and you have a black hole.  Or something :-)

My point is that before you reach to invent new syntax, see if there's
a way to do what you want with the existing syntax.  I have a document
coming on this to try and point people who want to give meaning to
every possible combination of punctuation and alphanumerics in the
right direction.

Perl is already very hairy and full of punctuational quirks.  I think
we need a fairly compelling argument.

> I have a list of stuff that looks a lot like a hash:
> 
>       ( foo => 1, bar => 2 )
> 
> Now, gol dern it, I want to treat it like a hash.  I want *perl*
> to let me treat it like a hash.  Directly!

A hash is a specific data structure, currently encapsulated in the
innards as an HV.  What you have is a list.  You can assign that list
to a hash, in which case Perl builds an HV for you.

> If not
>       keys ( foo => 1, bar => 2 )
> then
>       keys %( foo => 1, bar => 2 )

I personally prefer:
  ('foo', 'bar')
or even
  qw(foo bar)
for that.

Seriously, how many times do you want to call keys or values on
a list and then never do anything else with it?  Very very rarely.
Most of the times you say:

  foreach $foo (keys %bar) {
    # do something with $foo and $bar
  }

or at the very least you save away the list of keys and do something
with the corresponding values later on.

Yes, there are a few situations (e.g, where the presence of the key in
the hash is important not the actual value stored with the key) where
you might want the keys returned by a function but nothign else.
But those are mighty mighty rare.

In those mighty rare cases, I say you should have to deal with:

  keys %{{ foo() }}

Nat

Reply via email to