develooper Front page | perl.perl5.porters | Postings from June 2008

Control flow ops, dead code, warnings

Thread Next
From:
Yuval Kogman
Date:
June 28, 2008 09:30
Subject:
Control flow ops, dead code, warnings
Message ID:
20080628162933.GI23537@woobling.org
Under use warnings we get warnings for useless use in void context.

A somewhat related thing is expressions which involve two
conflicting types of control flow:

	my $value = return "Foo";

	redo && foo();

etc.

Maybe this is worth a warning, since that code can never be reached?


Some edge cases:

Obviously this shouldn't warn:

	return "foo";
	foo(); 

Nor should:

	foo() && redo || bar

But this should:

	redo || bar

as should

	foo() && ( redo || bar() )

So, I think it boils down to an unconditional control op (return,
redo, goto, last, next) in an expression the 'first' of a logop

-- 
  Yuval Kogman <nothingmuch@woobling.org>
http://nothingmuch.woobling.org  0xEBD27418


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About