ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martijn Kruithof <...@apache.org>
Subject Re: svn commit: r393996 - /ant/core/trunk/src/main/org/apache/tools/ant/launch/Launcher.java
Date Fri, 14 Apr 2006 15:22:06 GMT
Antoine Levy-Lambert wrote:

>I also think that the code was more readable before. The variable
>myTokenizer or tzr being a variable of a private function goes quickly
>out of scope anyway.
>
>Something like this would alleviate the remark of Martijn concerning
>where the incrementation takes place but does not seem to be proper java
>syntax.
>for (StringTokenizer tzr = new StringTokenizer(path, File.pathSeparator)
>&& String elementName = tzr.nextToken();
>tzr.hasMoreElements();elementName = tzr.nextToken()) {
>  
>
To be honest I don't really like this for loop either, the && in the 
initializer of the loop doesn't make it more readable.
My general feeling is that "funny" constructs used to reduce scope by 
just defining something inside the loop control statement is that in 
that case a method should be used to reduce the lifetime and scope of a 
variable.

In the case of the changed loop, the scope of the variable was not 
reduced by any statement. (Method terminates directly after the last 
statement of the loop.)

Generally I am more in favour of creating an extra method, than to 
introduce unclear constructs to reduce scope.
(And in this case the method is already limited to the action in the loop.)

Martijn

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message