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

"Indicate" is not the same as "create" and I never said "create"!! And we were talking about in certain situations/context yet your examples are all over the map. We're clearly not on the same page.

Elda Taluta; Sarks Sark; Ark Arks

Replies are listed 'Best First'.
Re^10: Why? (each...)
by ikegami (Patriarch) on May 13, 2011 at 19:32 UTC
    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).

      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);