5 ms·
Something can be mindbending in its implementation, but offer a very convenient interface at the same time. If mindbending isn't relating to its usage, but to
by zelphirkalt 2y ago
Something can be mindbending in its implementation, but offer a very convenient interface at the same time.
If mindbending isn't relating to its usage, but to its implementation, then I could see, how it could still be a good thing.
- exe34 2y agomindbending can also refer to something being deceptively simple. you might think it would be a big complicated mess, but using this one weird trick makes it really obvious what's going on.
- CyberDildonics 2y agoHow does that relate to a simple loop construct though? Why would you want that to be mind bending in interface or implementation? Every other language makes it as simple as possible.
- SatvikBeri 2y agoThis isn't really true – you have languages like Odin that only have a for loop, no while loop, that only supports index-based iteration. Then you have languages like Python that let you loop over an arbitrary iterable, and define your own iterables. Some languages allow conditionals in loops, some don't. Some let you loop over multiple iterables, while some only take one at a time. Common Lisp happens to be on the upper end of what loop allows – you can use it as a standard for loop pretty easily, but the interface gives you many other options.
- medo-bear 2y ago> Common Lisp happens to be on the upper end of what loop allows – you can use it as a standard for loop pretty easily, but the interface gives you many other options. If you really wanna get freaky try 'do. It is the heroin addicted cousin of 'loop https://www.lispworks.com/documentation/HyperSpec/Body/m_do_do.htm https://www.lispworks.com/documentation/HyperSpec/Body/m_do_...
- shawn_w 2y ago`do` is very straightforward and basic compared to the things that `loop` allows.
- medo-bear 2y agooh no. maybe you have in mind 'dolist or 'dotimes 'do is much more general and way more powerful. in some sense 'loop is the taming of 'do. see for example https://www.lispworks.com/documentation/lcl50/loop/loop-7.html https://www.lispworks.com/documentation/lcl50/loop/loop-7.ht...
- shawn_w 2y agoNo, I mean do. It's basically just a C style for loop except with a return value. Nothing special.
- medo-bear 2y agoyes the syntax for 'do is simple, like that of lisp. however 'do allows you to make far more complex iteration constructs than 'loop. 'loop is just a DSL to make some of these constructs more concise. read up on it
- lispm 2y agoLOOP has the DO functionality included. Example: CL-USER 18 > (do ((a 1 (+ a 1)) (b 10 (* b 1.5)) (c nil)) ((> a 5) (list a b (reverse c))) (push (* a b) c)) (6 75.9375 (10 30.0 67.5 135.0 253.125)) CL-USER 19 > (loop for a = 1 then (+ a 1) and b = 10 then (* b 1.5) and c = NIL then c when (> a 5) do (return (list a b (reverse c))) do (push (* a b) c)) (6 75.9375 (10 30.0 67.5 135.0 253.125))
- medo-bear 2y ago
- shawn_w 2y agoAnd then there's Scheme, where there are no iterative loops; all looping is done with recursion. You can build pretty much everything other languages do with loops on top of that, though.
- groovy2shoes 2y agoNot true. Scheme has `do`. See R7RS section 4.2.4 "Iteration".
- shawn_w 2y agoScheme's `do` is implemented using recursion. There's a sample macro for it in 7.3.