Continuations (hereafter, "Threads")

This describes continuations, or as we like to call them (rather confusingly), threads. Variables declared within a thread are local to the thread, but it inherits the scope of the caller when continued.

Inspiration from this concept comes from forum posters.

Declaring a thread:

    thread_name FIRST!!
      some_code_to_execute

      some_variable
      EDIT:

      code_to_execute_upon_continuation
    IBTL

(Reference: forum posters on WoW boards, trying to be the first poster. IBTL == In Before The Lock, signifying that forum mods will likely close and lock the thread.)

The 'EDIT:' keyword yields the value of the most recent statement to the calling routine. (Mnemonic: when you edit your thread post, you returned to the thread.) At IBTL, the thread yields the most recent statement.

Interaction with data yielded from a thread is done via thread handles. Thread handles either act as the returned data in variable context, or as a thread handle in thread context. To create a thread handle (a new instance of a thread):

    HAY thread_handle!  WUTZ GOIN ON IN thread_name THREAD?

To continue a thread:

    I SEE WUT thread_handle DID THAR

To force a thread to restart from the beginning:

    thread_handle BROKE TEH FORUMZ

Geordan Rosario (proxy for Eli Stevens, whose brainchild this really is), 2007/05/30 21:17


Very confusing…why not just use threads for threading? I proposed this yesterday on hey-guys

wohali, 2007/05/30 21:40

Another possible syntax for coroutines/continuations.

  I ARE TINYKITN
     BRB 1
     BRB 2
     BRB 3
     WOOT 4
  KTHXBAI

  LFG KITN NEED TINYKITN
  VISIBLE MOAR KITN PLZ
  VISIBLE MOAR KITN PLZ
  BTW and so on

Here I ARE declares a function, BRB is yield and WOOT return. LFG…NEED declares a coroutine thread aka thread , and MOAR…PLZ continues it. The example is a coroutine that returns 4 values in sequence.

Zombie, 2007/05/31 08:18

Those are coroutines, not continuations. Continuations are points in the program to which you can jump – like GOTO labels except that you can jump out of function calls (or back into them, if the implementation is up to it).

Copied from a post I made on gamedev.net:

BTW this program prints the numbers 10 to 20
HAI

CAN HAS STDIO?

I HAS A CONTINUATION

BTW this is a function declaration
SO IM LIKE COUNTING WITH START
    I HAS A COUNTER ITZ START MINUZ 1
    
    BTW this creates a continuation object and assigns it to CONTINUATION
    BTW this assumes lexical scoping
    IM MAKING A TIME PARADOX WITH CONTINUATION
    UP COUNTER!!1
    
    BTW this is a return statement
    I FOUND TEH COUNTER
KTHX

BTW this calls the above function
I HAS A NUMBER ITZ COUNTING WITH 10
VISIBLE NUMBER
IZ NUMBER LESS THAN 20 O RLY?
    YA RLY
        BTW this calls the continuation
        ZA WARUDO UR CONTINUATION
KTHX

KTHXBYE

Jon, 2007/05/31 08:48