Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A similar feature is found in Common Lisp's LOOP macro, <a href="http://www.gigamonkeys.com/book/loop-for-black-belts.html#setting-up-and-tearing-down" rel="nofollow noreferrer">described here by Peter Seibel</a>:</p> <blockquote> <p>...LOOP provides two keywords, initially and finally, that introduce code to be run outside the loop's main body.</p> <p>After the initially or finally, these clauses consist of all the Lisp forms up to the start of the next loop clause or the end of the loop. All the initially forms are combined into a single prologue, which runs once, immediately after all the local loop variables are initialized and before the body of the loop. The finally forms are similarly combined into a epilogue to be run after the last iteration of the loop body. Both the prologue and epilogue code can refer to local loop variables.</p> <p>The prologue is always run, even if the loop body iterates zero times. The loop can return without running the epilogue if any of the following happens:</p> <ul> <li>A return clause executes.</li> <li>RETURN , RETURN-FROM, or another transfer of control construct is called from within a Lisp form within the body...</li> </ul> </blockquote> <p>For example, part of a Python sample found in the linked question:</p> <pre><code>for v in known_variables: if self.bindings[v] is cell: return v else: raise CannotSimplify </code></pre> <p>might look something like this:</p> <pre><code>(loop for v in known-variables when (eq (gethash v (slot-value self bindings)) cell) do (return v) finally (signal cannot-simplify)) </code></pre> <p>Another observation:</p> <p>Common Lisp's condition system is also unique. Someone, once, asked where it came from and was pointed to <a href="http://www.nhplace.com/kent/Papers/Condition-Handling-2001.html" rel="nofollow noreferrer">Kent Pitman's paper</a>, where he says got it from Maclisp. Similarly, Common Lisp's weird-looking FORMAT function apparently came from Multics via <a href="http://danweinreb.org/blog/the-worse-is-better-idea-and-the-future-of-lisp#comment-28532" rel="nofollow noreferrer">Dan Weinreb</a>.</p> <p>The common thread is that language features don't tend to follow from the ancestor language that most inspired this language, but are taken by individuals who loved them to whatever new language they're working on. So if you want to find out the actual source of Python's <code>for</code>-<code>else</code>, I'd look for who added it, and see what language they worked on prior to that.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload