in reply to Re^2: A question about method return values and error checking
in thread A question about method return values and error checking

> f( name => get_name(), foo => 1 );

That's because the design of => is flawed.

It should enforce scalar context, if people want to use it as a pairing operator.

DB<106> sub tst { return } DB<107> x a => scalar( tst() ), b=>2 => ("a", undef, "b", 2)

And yes I know that Moose relies on this "feature", but you can't have it all.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^4: A question about method return values and error checking (=>)
by tye (Sage) on Nov 09, 2015 at 18:09 UTC

    Well, the Perl 5 implementation of => has that problem. I recall discussions of enforcing scalar context when => was still fairly new, but it was already too late. Then Perl 6 made it so.

    And the problems with return; from a sub that otherwise returns a single scalar go way beyond just uses of =>, of course.

    - tye        

      > go way beyond just uses of =>, of course.

      Well I had the Stop Using Perl discussion in mind.

      Using fat-comma + sub-call has unpredictable consequences, mainly b/c people are led to the misinterpretation that => is pairing two values like e.g. : is doing in JS.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!