Lecture overview -- Keyboard shortcut: 'u'  Previous page: Continuation Passing Style -- Keyboard shortcut: 'p'  Next page: Coroutines [Section] -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 3 - Page 34 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
Observations about continuation passing style

Based on the experiences with the programs on the previous page we make some observations about continuation passing style - CPS

  • Functions written in CPS are always tail recursive

    • In some cases at the expense of construction of a chain of lambda expressions - to be called when the recursion contracts

  • Tail recursive functions do not need to contruct new continuations

    • The original - outer continuation - is passed on in recursive calls

  • Functions written in CPS do not need 'the magic primitive' call-with-current-continuation

    • We can program in such a way that the necessary continuations are explicitly available

  • Functions written in CPS are specific about the evaluation order of sub-expressions

  • Functions written in CPS are 'convoluted', 'inverted' and difficult to read and write

    • Functions in CPS are typically automatically translated from functions in direct style

  • Functions written in CPS never returns

    • Can be implemented without a run time stack