On Thu, 2004-08-19 at 10:03, Luke Palmer wrote:
> Matt Diephouse writes:
> >     use CGI qw(:standard);
> >     
> >     my $foo = Bar->new(
> >         name => "Baz",
> >         value => param('baz'),
> >         something => 'else'
> >     );
> > 
> > See the problem? 
> 
> Yikes, yeah, that seems so innocent.

Not to the compiler it shouldn't.

First off, in Perl 6, I *think* that that C<< => >> will enforce a
scalar context (it's a tuple operator, last I recall).

Second, in Perl 5 it should not be hard to identify such situations for
warning purposes. C<< => >> may be a synonym for C<,>, but that doesn't
mean that you can maintain some little smidge of state in the op that
tells you that your right hand side should not be and expression that
returns a list of more or less than one element.

In very high-level terms, and without having looked at the op(s) in
question, I would assume the tree looks like:

        /---LHS->indentifier('value')
op(,) <
        \---RHS->invoke('param',constant('baz'))

So if C<op(,)> knows that it was originally C<< => >>, then it can issue
a warning (perhaps only in -w mode) when discovering that its RHS
yielded zero elements, and you're done.

Of course if that really turns into

        (value => (param('baz'), (something => ('else))))

then it gets harder, but it's still possible to warn correctly.

-- 
â 781-324-3772
â [EMAIL PROTECTED]
â http://www.ajs.com/~ajs

Reply via email to