Re: Declaring local variables inside loop

Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

tom fredriksen schreef:
Hendrik Maryns wrote:
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


I do some looping like this:

FunctionInputTuple tupleWithSecond;
while (tupleStates.contains(first)) {
tupleWithSecond = FunctionInputTuple.getInstance(
tuple.getSymbol(), tupleStates);
// do some computation, replace ?first? in the list
equivalent &= equivalence.equivalent(firstValue,

I have a question out of curiosity, since I have seen some of your other
posts. Are you perhaps thinking a bit too much of lists and Lisp/Scheme.
I am just curious as you are clearly demonstrating that chain of thought
in your comments and examples. My point is that it might be in the way
of utilising (or perhaps understanding) java correctly. i.e. writing
code that follows java idioms instead if Lisp, essentially using the
wrong language for how you think.

I do have some interest in Lisp, but I have never used it. Thing is,
part of what I am programming now (tree automata and manipulations
thereof) has been programmed before in Lisp, and I look at that code
from time to time to get some inspiration. So I might be contaminated
there. But I only do Java (until now). Just from time to time, I see
some useful constructs there, and would want to use them in Java too...

The question about lists could just as well be stated as a comparison
with Perl lists. This question is about coding style and performance, I
don?t see a link to Lisp here. In Lisp, this would probably involve
mapcars and stuff. If you want to enlighten me on the Java idiom of a
loop like the above, please feel free to do so.

Just a thought though.

You could have mailed this to me privately. Unfortunately, you
e-mailaddress does not work, so I have to clutter the NG with this.

Hendrik Maryns

Version: GnuPG v1.4.2 (GNU/Linux)