Michael Fowler wrote:
>
> On Wed, Sep 20, 2000 at 05:20:54PM -0700, Steve Fink wrote:
> > > $foobal = 3;
> > > if (@ARGV) {
> > > $foobar = @ARGV;
> > > }
> > >
> > > print $foobar;
> > >
> > > Only warn me that $foobar is uninitialized? I always prefer it when the
> > > actual source of my problem is pointed out, rather than its symptoms.
> >
> > It's exactly the same behavior as now, if you add in the "maybe it's a
> > typo?" guess. Which sounds fine to me.
>
> Except for the line number reported, which is the important part.
Oh. Certainly you'll get the line number. My description didn't include
it because it didn't seem to aid to the understanding. I have it in the
examples that I added to the RFC.
I suppose it could even give both line numbers for declared variables:
"use at line 7 of uninitialized variable declared at line 3."
> I would. I have not done it personally, but I do maintain code that has
> something along the lines of:
>
> my($foo, $bar, %baz, @qux, $quux, $blah ... ad nauseum);
>
> This new warning would make life difficult for me.
It's not just having my($long, $list, $of, $variables). It's never
saying $long = f().
Ah well. It would be interesting to have this and see how many things
complain. I know my code is littered with abandoned 'my $var's that are
no longer used, because I'm lazy and used to relying on a C compiler to
tell me when I can delete an obsolete local variable. Perl won't do that
for lexicals.
> > But do you like the feature of C where it warns you at compile time when
> > this is going to happen?
>
> Yes, and Perl currently has the very same thing, except with the additional
> warning when I use a variable that has not been declared. This being Perl,
> it's natural; you cannot use a variable in C without declaring it, so the
> issue never comes up.
Where it catches things for me in C is in places like:
int somefunc() {
int status;
while (...) {
status = syscall();
if (status < 0) break;
...
}
return status;
}
Before I started using -Wall all of the time, I was often puzzled when
somefunc() returned -813714631.