[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: call/cc



kragen@pobox.com writes:

> It also depends on how well your language supports closures.  Writing
> explicit CPS is more of a problem in C than in JavaScript or Scheme.

You can get away with it in C because you can cast types to void *,
but since C (and C++) don't have recursive function types, it is
difficult to write CPS style code `in the language' (i.e., making use
of the language features as intended).

> I like to think I already have CPS in my repertoire; I've written a
> few thousand lines in C and JavaScript that way, and I still think
> it's hard to read and understand.  You can't write compound
> expressions, your only control structure is "goto", and the extra
> noise in your source code introduced by defining functions, anonymous
> and otherwise, all over the place makes it still harder to follow.

You can use recursion and constructs other than `goto' (tail-recursive
calls) in CPS.

I don't find the excess noise that distracting in Scheme, but I really
wish there was a truly concise syntax for lambda expressions,
especially if they are to be used for CPS.  In other languages (such
as Java), the amount of excess noise is horrendous.