abusing exceptions for continuations

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gangesmaster

    abusing exceptions for continuations

    i've had this strange idea of using the exception's traceback (which
    holds the stack frame) to enable functional continuations, meaning,
    raise some special exception which will be caught by a reactor/
    scheduler/framework, which could later revive it by restoring the
    frame.

    i'm thinking of using the generator's implementation (some minimal
    support on the c-side)

    has this been tried before? what were the results?


    thanks,
    -tomer
  • Bruno Desthuilliers

    #2
    Re: abusing exceptions for continuations

    gangesmaster a écrit :
    i've had this strange idea of using the exception's traceback (which
    holds the stack frame) to enable functional continuations, meaning,
    raise some special exception which will be caught by a reactor/
    scheduler/framework, which could later revive it by restoring the
    frame.
    >
    i'm thinking of using the generator's implementation (some minimal
    support on the c-side)
    >
    has this been tried before? what were the results?
    I don't know, but you may want to have a look at Stackless Python.

    Comment

    • Paul McGuire

      #3
      Re: abusing exceptions for continuations

      On Dec 10, 2:39 am, gangesmaster <tomerfil...@gm ail.comwrote:
      i've had this strange idea of using the exception's traceback (which
      holds the stack frame) to enable functional continuations, meaning,
      raise some special exception which will be caught by a reactor/
      scheduler/framework, which could later revive it by restoring the
      frame.
      >
      i'm thinking of using the generator's implementation (some minimal
      support on the c-side)
      >
      has this been tried before? what were the results?
      >
      thanks,
      -tomer
      Simpy has a mechanism like this, for discrete event simulation
      modeling of processes and resources. Processes "run" for a while,
      then yield a delay or a hold on a resource, and are resumed later.

      -- Paul

      Comment

      • Lautaro Pecile

        #4
        Re: abusing exceptions for continuations

        On Dec 10, 5:39 am, gangesmaster <tomerfil...@gm ail.comwrote:
        i've had this strange idea of using the exception's traceback (which
        holds the stack frame) to enable functional continuations, meaning,
        raise some special exception which will be caught by a reactor/
        scheduler/framework, which could later revive it by restoring the
        frame.
        >
        i'm thinking of using the generator's implementation (some minimal
        support on the c-side)
        >
        has this been tried before? what were the results?
        >
        thanks,
        -tomer
        That idea has been tried here http://aspn.activestate.com/ASPN/Coo.../Recipe/474088

        It fails with algorithms which not use tail call recursion, and is
        veeery slow. Try with Stackless.

        Lautaro

        Comment

        Working...