in reply to Re^9: Why? (each...)
in thread Why? (each...)

It's even more far fetch that they indicate a list, and I pointed this out too. For every example you gave where it does, I gave examples where parens didn't indicate a list (high false positive ratio), and examples where lists existed without parens (high false negative ratio).

Parens are a low precision indicator of lists (not likely to be correct), and parens are a low recall indicator of lists (not likely to find instances of lists).

Replies are listed 'Best First'.
Re^11: Why? (each...)
by Argel (Prior) on May 14, 2011 at 00:12 UTC
    Look at the OP's question. Seems clear he is confused about when to use {}, [], and () in the context of variable creation/assignment. So with that in mind, given "my %hash = ( x => 'a', y => 'b', z => 'c')" the parens are used to indicate where the list of key/value pairs begins and ends. Ergo, they indicate a list. Yes, the comma operator provides the list context, but it's not useful for distinguishing when to use {}, [], or (). I was thinking more in terms of a "list of key/value pairs".

    Elda Taluta; Sarks Sark; Ark Arks

      Ergo, they indicate a list.

      No, they group expressions and change precedence. The list is there regardless of the presence or absence of parentheses. The parentheses only change the order in which Perl will evaluate the comma-separated expressions.

      Yes, the comma operator provides the list context....

      No, the assignment to the hash provides the list context. That's why you can write:

      my %hash = 1;

      ... and get a warning about an odd number of elements to a hash. No parentheses. No commas. Still a list.

      Counter example:
      sub g { return { ... } } sub h { return { ... } } my $hash = (f ? g : h);
        Using curly braces when parens were supposed to be used is right there, in the OP!! Hey, maybe that could be the context...? Why is that so hard to grasp? No matter. I think I finally understand why you and BrowserUK tangle from time to time! Well, I have been discussing this in a certain context the entire time and as best I can tell, you have not made an effort to grasp that. So, have a good weekend.

        Elda Taluta; Sarks Sark; Ark Arks