in reply to Re: tied, or modified?
in thread tied, or modified?

Isn't sub a higher priority than ->? (My noobness and I have no business commenting on such business, so I hope I don't offend anyone).

Welcome to Perlmonks, and feel free to dive right into the discussions without apology. Especially since you took the time to quote from the documentation in support of your answer, no offence was taken (or given).

I was surprised, not by sub {}->() parsing as (sub {})->() (though I had to try it to make sure that it was the case), but rather by tied sub {}->() parsing as ( tied sub {} )->().

Replies are listed 'Best First'.
Re^3: tied, or modified?
by Anonymous Monk on Oct 23, 2009 at 03:33 UTC
    It doesn't look like that is how it gets parsed (in 5.10.0):
    # perl -MO=Deparse,-p -e 'tied( sub {}->() )' tied({sub { } }->()); -e syntax OK
    In other words,
    tied( { sub {} }->() );
    which I think is equivalent to the following, because the braces there are denoting a block rather than a hash:
    <c> tied( ( sub {} )->() );
      Ah, still more fuel for my wild speculation! You have indicated the deparse-ing of tied( sub {}->() ), which is just as I expected; but I went back and checked the deparse-ing of tied sub {}->(), and it looks the same to me:
      $ perl -MO=Deparse,-p -e 'tied sub {}->()' tied({sub { } }->()); -e syntax OK
      I had assumed from the (ahem) reference to reference constructors that tie was gobbling up the sub {} before ->() could get at it, but that's obviously not the case. So: Since they deparse identically, why do tied sub {}->() and tied( sub {}->() ) give different error messages?