John Porter wrote:
> Come on.  What's so hard about knowing
> ( $x, $y, $z )
> is a bunch of variables, and
> my( $x, $y, $z )
> is a bunch of variables declared local.
> Answer: nothing.
>

If you see some code saying

    my $a, $b, $c;

Would you say $b and $c are subject to a different scoping rule than $a ? I
know I wouldn't!

It actually isn't hard for us to know `my' should have parenthesis when used
for more than one variable, but it's a difficult thing for beginners. The
fact with the <FHANDLE> makes the things even more hard for them.

Having `my' with the same precedence rules as `print' for example, would
probably end with these problems, while preserving the old-style.

    my $a, $b, $c;          # all the three are lexicals
    my ($a, $b, $c);        # idem

    my $a, $b, $c = @_;     # $c gets @_ in scalar context
                            # which is the same as:
    $a, $b, $c = @_;        # $c gets @_ in scalar context

    my ($a, $b, $c) = @_;   # the same as:
    ($a, $b, $c) = @_;

Only what would change is:

    func(\my $a, 1, 2);     # wouldn't work, but

    func(\my($a), 1, 2);    # or:
    func(\(my $a), 1, 2);   # would work.

and:

    otherfunc my $x => 1    # wouldn't work, but

    otherfunc my($x) => 1   # would work.

I don't think it's much of a change, since probably most code that did work
would continue to work, except for these cases above here, but I actually
think those aren't the most common cases of usage. Oh! Of course, there's
also the monster Bryan C. Warnock wrote:

    (my $a, $b, local $,, my $c) = @_;

This very common (I use it in all my scripts!) snippet would have to be
rewritten to the much more confuse

    (my($a),our($b),local($,),my($c)) = @_;

What is it, anyway? A joke? (There's Perl poetry, why can't be there Perl
jokes?) Who writes this kind of code anyway?

- Branden

Reply via email to