Fork me on GitHub
#clojure-dev
<
2023-08-06
>
Noah Bogart01:08:13

Why does the java impl of Clojure use for(; ;) ? There are places that have returns on every branch, so i'm not sure what's gained.

andy.fingerhut02:08:29

You mean, why for (;;) instead of while (true)

andy.fingerhut02:08:48

Or why an otherwise infinite loop if it didn't have return and/or break in its body?

andy.fingerhut02:08:23

If the first question, it seems like six of one and half a dozen of the other to me.

andy.fingerhut02:08:15

If the second question, then an otherwise infinite loop with explicit return or break statements is sometimes the most straightforward, easy-to-understand and write construct there is, especially if there is part of the loop body you always want to do at least once, and part that you might never want to do.

andy.fingerhut02:08:50

Out of curiosity, do you find such code unclear, perhaps?

Noah Bogart10:08:57

Why have it at all? LispReader’s method read has it and ends in an unconditional return statement. The body cannot loop.

Noah Bogart10:08:38

(Sorry to ask a question then immediately fall asleep lol)

Darin Douglass14:08:32

There’s a continue on line 288 which looks like makes it loop on “no op” macros

Noah Bogart15:08:25

Ope, i missed that. Thank you

2