in reply to Re^2: Some Insights from a Traveler Between Languages
in thread Some Insights from a Traveler Between Languages

Surely it's not a terrible burden to have to put parentheses around the stuff you are assigning to the array.

Then do.

I don't because it's unnecessary. Except for slicing the values returned from a function and creating a one-element lvalue list, I cannot think of a case where parentheses create lists. (I can also argue that in the former case, they don't either; they just mark a context.)

Put another way, if there are no precedence issues, why do you need to group a one-element list explicitly?

  • Comment on Re^3: Some Insights from a Traveler Between Languages

Replies are listed 'Best First'.
Re^4: Some Insights from a Traveler Between Languages
by skyknight (Hermit) on Apr 23, 2005 at 23:08 UTC
    I think that's skirting my main issue, though. Namely, I find it troublesome that it makes such a simple mistake so eminently possible. The fact that you have two ways of saying something and one of those two ways is extremely close to a totally different semantic meaning is just asking for trouble.
Re^4: Some Insights from a Traveler Between Languages
by ihb (Deacon) on Apr 26, 2005 at 22:09 UTC

    Does the parenthesis in (EXPR) x EXPR create a list (in list context)?

    ihb

    See perltoc if you don't know which perldoc to read!

      It creates list context for the x operator, which causes a list to be created.

      Caution: Contents may have been coded under pressure.

        It creates list context for the x operator

        Nope. The operand of any operator can't set which context the operator itself is in. It does set context for it's operand though. That's what's interesting. Illustration for those that don't know what Roy and I are talking about:

        sub context { print defined wantarray ? wantarray ? 'list' : 'scalar' +: 'void' } @foo = context() x 1; # "scalar" @foo = (context()) x 1; # "list"

        ihb

        See perltoc if you don't know which perldoc to read!