develooper Front page | perl.perl5.porters | Postings from August 2012

Re: fixing smartmatch just hard enough (and when, too)

Thread Previous | Thread Next
From:
Abigail
Date:
August 18, 2012 05:29
Subject:
Re: fixing smartmatch just hard enough (and when, too)
Message ID:
20120818123152.GA20610@almanda
On Fri, Aug 17, 2012 at 08:00:25PM -0500, Jesse Luehrs wrote:
> 
> I like the concept, but "when ({ ... })" reads kind of weird. Everywhere
> else in the language, ({ ... }) means a hashref - anything that means a
> block has some kind of leading keyword inside any potential parentheses:
> "(do { ... })", "(sub { ... })", etc. I think just leaving it as
> "when (sub { ... })" is probably going to be the least confusing.


Maybe that ought to be fixed ;-). After reading your statement, I tried:

  $ perl -wE 'sub foo (&) {say $_ [0] -> ()} foo ({1})'
  Type of arg 1 to main::foo must be block or sub {} (not anonymous hash ({})) at -e line 1, near "})
  "
  Execution of -e aborted due to compilation errors.
  $

I was surprised the parens are not allowed in this case.



Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About