Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Good day, fellow lispers

Name: Anonymous 2011-01-29 8:57

In following code, does "return-from all" frees mapcar's stack frame or would lead to stack overflow?

(defun all (fun xs)
  (mapcar (lambda (x) (unless (funcall fun x)
                        (return-from all nil)))
          xs)
  t)

Name: Anonymous 2011-01-29 19:11

>>18
Not that often, but if they make some code simpler (or sometimes for efficiency reasons), most people are okay with using them, especially if it's part of macros or generated code.

If writing the code in a pure manner looks nicer and works fine then there's no real reason to use any ``impure'' forms.

Myself, I have no qualms about using unwind-protect, I haven't used throw/catch in ages (although, macros that I've used may use it in their implementations - as I mentioned, some condition systems just use a bunch of gensym'd symbols and some of those special forms to implement themselves), and I sometimes use return-from if it makes the code simpler or more efficient. It basically depends on the situation.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List