7 ms·
praising 'loop' in the same post as describing lisp as 'elegant' shakes head
by NikkiA 1y ago
praising 'loop' in the same post as describing lisp as 'elegant' shakes head
- codr7 1y agoSome people seem to like it, and be very effective using it. The problem is it's a walled garden, with its own quirky syntax; nothing that happens inside of loop is applicable outside, and the other way around.
- shawn_w 1y agoI feel bad for people who haven't discovered ITERATE yet.
- Jtsummers 1y agoITERATE still breaks when you use `count` inside it, the built-in CL function. If they ever address that problem I'll get back to use it but having a time bomb in my programs isn't something I like. Trivial example of breakage: (iter (for i from 1 to 10) (print (count i some-sequence)))
- shawn_w 1y agoBreaks how? I'm on my phone, not a computer right now and can't test, but that should call the CL function - ITERATE uses `counting` for that particular operation to avoid conflicts; see https://iterate.common-lisp.dev/doc/Gathering-Clauses.html https://iterate.common-lisp.dev/doc/Gathering-Clauses.html Or is the documentation wrong?
- Jtsummers 1y agoApparently this is a quicklisp problem, they haven't updated the release since 2021 when it was still broken.
- shawn_w 1y agoI just grabbed the latest ITERATE source off of its gitlab repository, and, yeah, that bit is still giving an error: Iterate, in (COUNT I SOME-SEQUENCE): Missing value for SOME-SEQUENCE keyword as well as WARNING: COUNT appears to be used as an ITERATE clause keyword, in this sexpression: (COUNT I SOME-SEQUENCE). This use is now deprecated and will cease to be supported in a future version. Please use the alternative keyword COUNTING instead. If you intended COUNT to be interpreted as a function call, instead of an ITERATE clause, you must find an alternative way of calling it, at present, perhaps by using FUNCALL or APPLY. Have to use (iter (for i from 1 to 10) (print (funcall #'count i some-sequence))) Guess the documentation /is/ wrong (for now, until the code finishes catching up)
- Jtsummers 1y agoWell, some-sequence was obviously an example, you'd have to fill it in with an actual sequence. Put in '(1 2 3) instead or assign something to it. But yeah, that's still not something I intend to use if they make you work around what should be plain Common Lisp.
- shawn_w 1y agoI had a some-sequence variable defined. (Using a literal list or vector gives a different error)
- BoingBoomTschak 1y agoIt's been marked as deprecated for some time, but still needs manual removal as of now: https://gitlab.common-lisp.net/iterate/iterate/-/blob/master/iterate.lisp?ref_type=heads#L1055 https://gitlab.common-lisp.net/iterate/iterate/-/blob/master... (removing https://gitlab.common-lisp.net/iterate/iterate/-/blob/master/iterate.lisp?ref_type=heads#L2882 https://gitlab.common-lisp.net/iterate/iterate/-/blob/master... should work, I think). Still better than the loop abomination, IMO.
- kazinator 1y agoI made a loop macro using the C preprocessor, for the Awk language. I had to rub my own eyes to believe that such a thing is possible. It comes with over twenty useful clauses. Clauses are programmer-definable. Clauses can combine in parallel or nested/cross-product iteration. https://www.kylheku.com/cgit/cppawk/about/ https://www.kylheku.com/cgit/cppawk/about/
- Jach 1y agoI'll never understand the love for iterate. Look at these comparisons: https://github.com/sabracrolleton/sabracrolleton.github.io/blob/master/iterate-loop.md https://github.com/sabracrolleton/sabracrolleton.github.io/b... For almost all of them, it's the same guy, just more parens. Nothing to love/hate for one or the other, it's just preference, though one is built-in.
- shawn_w 1y agoLooks more lispy because the parens. Plus it's extendable unlike LOOP, so you can make it work with your own data types. And a few other nice features like being able to collect into a vector or other sequence, not just lists.
- BoingBoomTschak 1y agoThe big plus for me is that the ad-hoc if/when/do are removed in favour of the standard operators, without the horrible then/else/end/and dance. Then you got all the life-improving goodies (in-{sequence,string,file,stream}, index-of-*, previous, etc...) that really add up to something.
- kagevf 1y agoMy opinion of LOOP started to change when I read (the much maligned) "Land of Lisp" and went over that "periodic" diagram in TFA. Seeing the elements of LOOP broken down like that went a long way to get me to overcome my original aversion to it.
- Jach 1y agoWho is maligning Land of Lisp?
- kagevf 1y agoHere's an example: http://metamodular.com/Books/land-of-lisp.html http://metamodular.com/Books/land-of-lisp.html
- Jach 1y agoHuh, didn't realize that beach didn't like it so strongly. Still, hardly "much maligned"... My impression was that most people enjoyed it, even though it definitely has some weaknesses and could (especially now 15 years later) use a second edition, if for no other reason than to move off CLISP to SBCL. This seems supported by its high reviews on Amazon and GoodReads. (Of course overall I liked it too, and we got the best music video about lisp out of it.) FWIW my own criticisms were largely style-based: too much of it felt like Scheme code rather than Lisp code, even outside of emphasizing/educating about the more primitive features, with lots of things like inner functions, recursion where looping would have IMO been clearer, and so much use of raw car/cdr/caadr/caddr/whatdr instead of more clearly structured structs or classes or just helper functions called intuitive things like get-foo. (The book Calendrical Calculations: The Ultimate Edition uses lists for all its data structures but helpfully creates many functions to both construct and access their parts. e.g. generic dates are a (year month day) list, but the definition and exclusive use of standard-year, standard-month, and standard-day for getting at them would let one refactor it into a class. There are also functions like gregorian-date, julian-date, and egyptian-date that have exactly the same implementation (making a list of the 3 passed params) but serve as 'typed' list constructors, and indeed could be refactored into something that carried along type information without changing other code.)