←back to thread

266 points awkravchuk | 1 comments | | HN request time: 0s | source
Show context
Guthur ◴[] No.41870173[source]
The event loop is brilliant example for how much `loop` is a full blown iteration DSL... love it or hate it ;)
replies(2): >>41870202 #>>41871308 #
awkravchuk ◴[] No.41870202[source]
I used to scoff at it at first, but after a few years of CL programming loop is one of my favourite CL constructs :)
replies(1): >>41870359 #
taeric ◴[] No.41870359[source]
I'm with you there. Is a bit of a mind bend, as I really disliked it the first few times I saw it.

For an even sillier mind bend, I'm using tagbody to be able to directly transcribe some of Knuth's algorithms as I am learning them.

replies(2): >>41870528 #>>41870541 #
CyberDildonics ◴[] No.41870528[source]
I don't understand why turning a simple loop into a 'mindbend' is considered good. The downfall of programming is complexity, if you're getting your mind blown by a loop how are you going to do the rest of the program?
replies(4): >>41870582 #>>41870627 #>>41871087 #>>41872673 #
zelphirkalt ◴[] No.41870582[source]
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.

replies(2): >>41870793 #>>41871078 #
CyberDildonics ◴[] No.41871078[source]
How 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.
replies(1): >>41872449 #
SatvikBeri ◴[] No.41872449[source]
This 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.

replies(2): >>41872733 #>>41873366 #
shawn_w ◴[] No.41873366[source]
And 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.
replies(1): >>41875683 #
1. groovy2shoes ◴[] No.41875683[source]
Not true. Scheme has `do`. See R7RS section 4.2.4 "Iteration".