
"Chris" == Chris Clearwater
writes:
Chris> Sarcasm, Kevin, sarcasm. :) Why is it that those who most need to point out that they were joking are least able to see it in others? Chris> The difference is with the CPS way it is implicit. For Chris> example take the Y combinator written using both methods Chris> (again this is pseduo code, not intended to be real haskell Chris> code or run in hugs) That's a funny definition of "implicit". All you need to delay evaluation is lambda. You're performing a CPS transformation as a way to insert a lambda in the proper place. BUT THAT'S NOT NECESSARY. Just write the lambda where you want it. You don't need to abstract over a continuation to delay evaluation, you can abstract over anything at all (it doesn't matter what). And you only ever apply the most recent continuation (notice how you could use the identifier "c" for every one of your continuations?). You don't have to apply c to pass a value to the current continuation, there's alread a way to do that: just return the value. Chris> Using the lambda way: Y f = f (lazy Y f) Then writing ones Chris> would be something like: ones_fix f = 1:(force f) Chris> Now the CPS way: Y f c = c (f (Y f)) Now writing ones: Chris> ones_fix f c = c 1:f Your translation is wrong. Here's the correct "lambda way" (in the same pseudo functional language): Y f = \ () -> f (Y f) where I didn't presume any "delay" or "lazy" macro. Here's ones_fix: ones_fix f = \ () -> 1 : f Compare to: Y f = \ c -> c (f (Y f)) ones_fix f = \ c -> c (1 : f) Which one seems to be more "implicit"? Where you abstract over a continuation to delay evaluation, I abstract over anything I feel like. Where you apply a continuation to a value, I just return a value. Where you would pass in a continuation to a CPSed function, I would just apply the result to some suitable token (unless I had zero argument functions) (that is, I would "force" an expression wherever you would pass a continuation to a CPSed function). You've performed a CPS transformation, but you never do anything *interesting* with the continuation. That might suggest that, whatever you seem to have achieved, it didn't come from the CPS transformation. Chris> Notice how the CPS way behaves as if it were actually Chris> passed itself, while the lambda way behaves as if it were Chris> passed itself quoted with lambda. The lambda way seems Chris> like a hack while the CPS way feels consistant. I guess I don't understand. Change "\ c ->" to "\ () ->". Remove the application of every "c". Change occurrences of "c" in argument position to "()". -- Kevin S. Millikin Architecture Technology Corporation Research Scientist Specialists in Computer Architecture (952)829-5864 x. 162 http://www.atcorp.com