Hacker News new | past | comments | ask | show | jobs | submit login

One word: loop :-)

(It's a bizarre, mini language for looping constructions and terrifying animals and small children.)




  (loop for i from 10 upto 20
        do (print i))
what does it do? Maybe it prints the numbers from 10 upto 20?

    (loop for element across vector
          sum element)
Hmm, what does it do? Maybe it sums all the elements of a vector?

Ada:

  for E of The_List loop
     if Is_Prime(E.P) then
        E.Q := E.Q + X;
     end if;
  end loop;
Lisp:

  (loop for e in the-list
        if (primep (p e))
          do (incf (e q) x))
Totally weird and bizarre how it looks similar.

Even stranger:

  (
  loop for e in the-list
       if (primep (p e))
          do (incf (e q) x)
       ; end if
  ; end loop
  )


"The Anatomy of a Loop", Olin Shivers. http://www.ccs.neu.edu/home/shivers/papers/loop.pdf

And that's in Scheme, so it doesn't look like someone dropped a chunk of Algol in your coffee.


Which explicitly mentions loop systems for Lisp as its inspiration: Yale Loop and Jonathan Amsterdam"s excellent ITERATE.


I use simple loop constructs like the above all the time; it's especially useful for collecting. But elaborate loop constructs in their full glory are impossible to understand and IMHO should be banned from use on any software engineering team.


Seen pretty elaborate loop constructs in large Common Lisp code bases I was working on, and my conclusion is that the only thing that should be banned is lack of willingness to spend 30 minutes at some point learning the loop syntax. Seriously, after you write few loops on your own e.g. collecting over several hash tables in parallel, you won't have much problem anymore.

I still feel current generation of programmers has a learning phobia.


Yeah, LOOP is super un-lispy. Dick waters is a great guy but I never liked LOOP and never use it.


What does it have to do with him?

The basic idea comes actually from Interlisp and Warren Teitelman‘s ‚Conversational Lisp‘ and its FOR macro.

The main purpose of LOOP is to question ones assumption what is Lispy and what not. ;-)


Pretty sure Dick wrote LOOP. There was an ai working paper on the subject by him iirc too. Teitelman had left mit by the time I got there, though I later got to deal with DWIM (which seems to have infected web browsers and npm etc :-( ) at PARC. one great titlemanism was the addition of ] to Interlisp.


Are you sure you are not mixing this up with the Series system, where Richard Waters wrote a bunch of papers on?

The paper from 1980 on 'LOOP Iteration Macro' by Burke&Moon does not mention him at all.

http://www.dtic.mil/dtic/tr/fulltext/u2/a087372.pdf


Ha, that's a funny scan! I have a paper copy of that memo someplace.

Yeah, I might be misremembering.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: