in reply to Re: (5.6.1) map mayhem? (+{ {;)
in thread (5.6.1) map mayhem?

IMO Perl should always interpret an opening brace right after the map and grep keywords, as the start of a block. There's no excuse for it, preferring to treat it as an anonymous hash.

Do you ever think you're seeing an anonymous hash in that position? I didn't think so.

Replies are listed 'Best First'.
•Re: Re: Re: (5.6.1) map mayhem? (+{ {;)
by merlyn (Sage) on Oct 07, 2003 at 21:42 UTC
    That might be the obvious case in hindsight. But you can't change the DWIMmery radically now, without having something subtly being made different. Also, I think it's the same DWIMmery used at the beginning of a statement that might also be a return value for a subroutine: you sometimes want that to be a block, and sometimes and hashref, hence the DWIMmery.

    Personally, I find the "+" prefix and ";" suffix to that open brace a bit tacky, but certainly a lot better than having a language force me to always use 8-space tabs just to make sure that lined up things stay lined up since the lineup is syntactically significant. {grin}

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      but certainly a lot better than having a language force me to always use 8-space tabs just to make sure that lined up things stay lined up since the lineup is syntactically significant.

      Not sure which language you are talking about, but I take Pythons or make's significant whitespace rules over the Perl significant whitespace rules (both of perl5 and perl6) any day, and twice on Wednesdays.

      At least the rules in Python and make make sense, those of Perl don't.

      Abigail

Re: Re: Re: (5.6.1) map mayhem? (+{ {;)
by diotalevi (Canon) on Oct 08, 2003 at 01:03 UTC

    If you're me you do. I rarely ever use blocks with map - if I've got braces then its going to be a hash (though the dwimmery forces me to prepend a '+' to make it behave).