From: Ian Jackson Subject: Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exiting via last" warning Date: Fri, 18 Dec 2015 14:39:42 +0000 Message-ID: <22132.6830.950656.416870@mariner.uk.xensource.com> References: <1450371968-27997-1-git-send-email-ian.jackson@eu.citrix.com> <1450371968-27997-6-git-send-email-ian.jackson@eu.citrix.com> <1450373473.4053.147.camel@citrix.com> <22130.62853.68527.604758@mariner.uk.xensource.com> <1450375801.1617.86.camel@citrix.com> <22131.320.250211.170343@mariner.uk.xensource.com> <1450437258.4053.198.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9wCC-0001vX-8Y for xen-devel@lists.xenproject.org; Fri, 18 Dec 2015 14:39:48 +0000 In-Reply-To: <1450437258.4053.198.camel@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [OSSTEST PATCH 6/9] db_retry: Suppress an "exitin= g via last" warning"): > On Thu, 2015-12-17 at 18:38 +0000, Ian Jackson wrote: > > Both of these are intentional.=A0=A0Perl thinks they might not be. > = > ... and that's because it is a common enough mistake to think that next or > last exits only the scope of the eval and therefore in this case to expect > it to run "last if !length $@;", while it actually wont. Yes. > I would have expected that if you want to successfully exit (i.e. not die) > the eval early and continue on with the remainder of the loop you should > use return, and=A0http://perldoc.perl.org/functions/eval.html=A0seems to = back > that up ("the value returned is the value of the last expression evaluated > inside the mini-program; a return statement may be also used,"), but > earlier you said that return would generate the same warning, so I remain= a > bit confused. Oh! I was confused about the effect of `return' in an eval. I expected it to exit past the eval and return out of the calling function. > According to my reading of eval.html "return if $db_retry_stop eq 'abort'" > would exit the eval with $@=3D"" ("If there was no error, $@ is set to the > empty string", it mentions last and goto bypassing this, but not return). > Then since length "" is false that outer last would be run insteadand we > are done with the loop as we wanted. AFAICT that would avoid the warning > for the inner last, but is not usable for the inner next, and in any case > using last inside the eval is actually more obvious in this instance, once > one thinks one understands an eval (which in my case is still debatable I > think) I still think this reasoning about `return' is more fiddly than just saying `last' or `next' when we mean `last' or `next'... Particularly given that, now, there is a `no warnings qw(exiting)' to cue the reader that they may need to check the FM. Ian.