in reply to Re: About the + in front of a hashref that disambiguates from a code block.
in thread About the + in front of a hashref that disambiguates from a code block.

I'm pretty sure unary plus existed very early in Perl (it makes perfect sense for it to have been included in the first version of the expression grammar). Not only did early unary + not numerify, I verified that in Perl 4 unary + didn't even impose scalar context.

Now, unary minus actually did numerify in Perl 4. It was early in Perl 5 when unary minus was taught to just prepend '-' when applied to a string. And I think there was a slight delay between that and -(-bar) being taught to yeild '+bar'. There was also some early finagling to make -bar => ... not complain about 'bareword' even under 'use strict;'.

- tye        

  • Comment on Re^2: About the + in front of a hashref that disambiguates from a code block. (unary -)
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: About the + in front of a hashref that disambiguates from a code block. (unary -)
by JavaFan (Canon) on Oct 24, 2009 at 22:39 UTC
    Not only did early unary + not numerify
    Late unary + doesn't numerify either:
    $ perl -wE 'say +"foo"' foo $
      We know because the question was whether it had always been that way.