3 ms·
I was coming from the Lisp perspective! Or at least Clojure... Maybe it's a language issue. I would say a 'loop' has a jump and a condition. So that's 'for', '
by afandian 8y ago
I was coming from the Lisp perspective! Or at least Clojure...
Maybe it's a language issue. I would say a 'loop' has a jump and a condition. So that's 'for', 'while' and 'do' in C, JS, Python, Pascal, Java...
Lots of languages including Lisp have recursion, maps etc but I wouldn't call that looping. Clojure even has TCO recursion but it only returns one value, not a sequence (unless you accumulate the whole thing)
- taeric 8y agoBut even the LOOP macro has returned values for a long time. It isn't even hard to see how the new stream/collect API if Java is just approaching what LOOP has been doing for decades.
- afandian 8y agoOK agreed there's a construct called loop that returns a single value. My original point was that list comprehensions are closer to sql projections than loops.
- taeric 8y agoApologies, I meant my point more as amusement than winning an argument. I am just now reading Practical Common Lisp, and amusingly one of the first things they do is build a simple query language. Didn't even use loop. So, to your point, the imperative commands of looping can be far removed from what people today call comprehensions. That said, I don't think it is inherent. Just a quirk of history.
- afandian 8y agoNo point scoring inferred. In fact, it's a great illustration of different language and technology communities taking words and ideas and implementing them differently, crucially, with different degrees of specificity.
- dfox 8y agoJava's streams implement the same idea as Common Lisp's streams, which were supposed to be more Common Lisp-like replacement for LOOP (eg. composable and with syntax that does not involve string comparison of symbols). That idea was droped from the final ANSI standard.
- lispm 8y agoSERIES, not streams.