[DFW.pm] Homework for the list, and for Oct 08 meeting
Patrick R. Michaud
pmichaud at pobox.com
Thu Sep 11 13:05:03 PDT 2014
On Thu, Sep 11, 2014 at 02:42:16PM -0500, Robert Flach wrote:
> Yet another way to do it. Interesting. I would have assumed that
> the unary + would have caused a numeric contextual evaluation of the
> contents of the parens, causing the string prints to print zero
> instead, but it works a charm. Nice
Coming from the Perl 6 world, it feels SO WRONG to me that a
numeric context operator isn't producing a numeric result. It's
one of those "OMG special case" exceptions that drive newbie
Perl 5 programmers nuts, and definitely doesn't follow the
principle of least astonishment.
So yes, it works, but it's not something I'd encourage or want to
see in code. :)
FWIW, Perl 6 avoids this altogether by using whitespace to know
when parens are part of the subroutine call syntax:
print(2+3) * 7 # parens belong to "print" call
print (2+3) * 7 # parens don't belong to the "print" call
Pm
More information about the Dfw-pm
mailing list