Call Queue

Call Queue is an idea for a queue-based esoteric programming language, thought of by User:Koen in 2013. Basically, a program in Call Queue looks like a program in your average imperative programming language, except functions are executed using a "call queue" instead of the usual call stack.

Call Queue was inspired by the similarities between a queue-based algorithm implementing breadth-first search in a tree, and a stack-based algorithm emulating recursion.

Syntax
A program in Call Queue is a set of function declarations. A function declaration consists in the function prototype, which informs its name and its arguments, and the function body, which is a sequence of statements.

A statement is either an atom or a function call. Atoms are built-in minimal functions.

One of the functions must be named.

Execution
When execution starts, the body of the function  is converted into a queue of statements, thereafter referred to as the call queue.

Execution proceeds in a loop:
 * While the call queue isn't empty
 * Dequeue the first element from the call queue
 * If it is an atom, execute it.
 * If it is a function call, append its body (as a queue of statements) to the call queue

Atoms
''This section is empty. Call Queue is yet unfinished.''

Example programs
Since the atoms haven't been defined yet, it is currently impossible to write a real program in Call Queue. The following is a dummy program that illustrates how execution unwraps, assuming the single-letter words in capital are atoms. function a { A; c; d; } function b { B; e; f; } function c { C; } function d { D; } function e { E; } function f { F; } function main { M; a; b; } The call queue would develop as follows: M a b a b b A c d A c d B e f c d B e f d B e f C B e f C D e f C D f C D E C D E F D E F E F F Finally, atoms have been executed in the order.

This is different from usual programming languages using a call stack, where such a program would end up with atoms being executed in the order.

Implementations

 * if Call Queue (files)