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

RETURN-FROM

Name: Anonymous 2011-12-12 12:55

Is it a good practice to use return? Is it a good practice to use continuation-passing-style, where one specifies several return paths?


(defun test (x a b c)
  (cond ((< x 0) (funcall a))
        ((= x 0) (funcall b))
        (t       (funcall c))))

Name: Anonymous 2011-12-12 12:56

You should always return your anus

Name: Anonymous 2011-12-12 13:01

stop making procedural lisp code.

Name: Anonymous 2011-12-12 13:02

While there's nothing particularly wrong with CPS it seems to be somewhat obfuscated. I can't remember why, but I have found occasion to write things directly in CPS, it made sense at the time, but I am having a hard time thinking of it now. In some cases you can get by with things like "todo" data that is accumulated, if the continuation is relatively local this kind of data flow is clearer than creating closures and continuations IMO.

The only benefit of CPS is that everything is a tail call. If you're trying to turn a recursive algo into an iterative algo then a little mechanical CPS conversion can help one find the right structure. (But you'll still probably pass POD rather than continuations.) Especially for some simple tree recursion you can manage this if the problem is not too generic.

Name: Anonymous 2011-12-12 13:03

>>3
But you can implement return and return-from through call/cc!
Even Haskell folk would agree, return-from is purely-functional!

Name: Anonymous 2011-12-12 13:50

is it better to have multiple return statements or setting a variable to the value and only have 1 return statement at the end that is the quesiton

Name: Anonymous 2011-12-12 14:32

>>6
But that's not passing a continuation. That's calling a function.

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