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

I was thinking of two things: when "()" is used to indicate you want or have an empty list, and then more for reading source code, where parens often indicate to the reader that he is looking at a list. The parens in foreach(), my($x,$y,$z)=@_, etc. Or e.g. in the case of %hash=(x=>"a",y="b") the parens indicate a list of key/value pairs. Or to put it differently, they indicate it's not an array and not a hash (and not a scalar).

Elda Taluta; Sarks Sark; Ark Arks

Replies are listed 'Best First'.
Re^6: Why? (each...)
by ikegami (Patriarch) on May 12, 2011 at 23:53 UTC

    where parens often indicate to the reader that he is looking at a list.

    You say foreach (), I say while () and if ().

    You say my ($x,$y,$z) = @_;, I say ($x+$y+$z)*$n.

    The parens in foreach(),

    The parens of foreach not even part of the expression, and the list is still created when you omit them.

    say foreach "a", "b";

    Or to put it differently, they indicate it's not an array and not a hash (and not a scalar).

    Really?

    $s = ($x); %h = ($x); %h = ([]);

    Your model has too many holes to count :(

    Simple model: A list is created whenever something is evaluated in list context.

      >The parens of foreach not even part of the expression, and the list is still created when you omit them.

      say foreach "a", "b";

      Well, you know that postfix-commands follow different syntax rules!

      Cheers Rolf

        My point is that the idea that parens create a list is flawed. How is that relevant?