in reply to Re^2: How should named paramater keys be named?
in thread How should named paramater keys be named?

I was worried about even posting the reply because I haven't a good story for why it should work apart from Perl DWIMery. As you point out it's not documented as providing that behaviour in any obvious place.

On the other hand it would break a huge amount of code should that behaviour change so I'd guess it ought be safe enough to use.

True laziness is hard work
  • Comment on Re^3: How should named paramater keys be named?

Replies are listed 'Best First'.
Re^4: How should named paramater keys be named?
by kejohm (Hermit) on Jun 28, 2011 at 05:21 UTC

    perlmodstyle mentions the use of named parameters with a leading hyphen.

      Great find! It partially supports Damian Conway's Perl Best Practices, except that he advocates for an anonymous hash, like this:

      my $obj = This::Class->new( { that => 2, those => 4 } );

      He makes the point that a missing 'value' with this strategy would result in compile-time error this way rather than a runtime problem.

      Regarding perlmodstyle's mention that the hyphenated parameter tag is based on an antequated need, it does confirm that the behavior of the fat comma is supposed to quote strings with hyphens in them (even at the beginning). So perl and perlmodstyle are both at odds with perlop as to what should qualify for the fat comma's quote-like behavior.


      Dave