John Porter wrote:
> > Well, for me, it isn't useful, unless you can show me I'm wrong. At
least
> > give me an example that shows it's more useful this way.
>
> First, we must always remember that whatever we do, we can
> force explicit precedence through the addition of parentheses.
> The cases we're concerned about, then, are ones in which
> parens are omitted.
>
> my( $a, $b, $c ) = /(\w+)/g;
>
> Natural enough, right?  Suppose I wanted to use non-my vars here.
>
> ( $a, $b, $c ) = /(\w+)/g;
>
> Under your proposal, these must both be equivalent, respectively, to
>
> my $a, $b, $c = /(\w+)/g;
>
> $a, $b, $c = /(\w+)/g;
>

Wrong!!! You mix up my proposal (which is make `my' have less precedence
than `,' and `=') with Bryan's one, which is to make everything with `,' be
implicitly a list. In the case of my proposal, the code above would be
translated to:

    my( $a, $b, $c ); $c = /(\w+)/g;

    $a, $b, ($c = /(\w+)/g;

If you want a list assignment, you still have to use the parenthesis, like
you did above.

    my ($a, $b, $c) = /(\w+)/g;    # or
    (my $a, $b, $c) = /(\w+)/g;

List assignment and declaration of lexical scope are different, but as the
declaration of lexical scope can be applied to a list, it should follow the
same precedence of list operators, ie. `print', that doesn't *require* but
*allows* parenthesis.



> I think we can all agree that last won't DWIM, unless the
> precedence of the comma operator is changed.
> So this illustrates why the issue is not one of changing the
> precedence of 'my', but of the comma operator.
> It must be lower (i.e. bind tighter) than assignment,
> comparison, and the various "operator" functions.

Agreed. I don't want to change the precedence between `,' and `=', I only
want that `my' behaves in relation to those the same way `print' does. Even
these two not being (or doing) the same thing, or even comparable things,
they both get lists (agreed, different lists, `my' needs a list of
variables) and they both should behave the same when lists are given to
them.


>
> This would upset the entire structure of perl's usefulness.
>

You're completely right. Messing with `,' and `=' is a bad idea.

> --
> John Porter
>
> You can't keep Perl6 Perl5.
>
>


- Branden

Reply via email to