pbrain

From Esolang
Jump to: navigation, search

The pbrain programming language is an extension of the brainfuck programming language that adds support for procedures. This is done with the addition of the instructions :, (, and ) to the existing brainfuck instructions. pbrain was created by Paul M. Parks in 2004.

A procedure is delimited by the ( and ) instructions. It's assigned a numeric identifier equal to the contents of the active cell at the time the ( is encountered. For example, the following pbrain program creates a procedure numbered "1" that will increment the active cell and move one cell to the right:

+(+>)

To call this procedure, the active cell is set to 1 and the procedure is called with the : instruction. Assuming the current cell is zero, the following will call the above procedure:

+:

Criticism[edit]

While pbrain adds procedures, the procedure that is called depends on the value in a cell which can change during execution. This means that one cannot always determine which procedure is being called just by reading the code. The code must be executed to determine the cell value and therefore called procedure. This is a disadvantage for code conversion but an advantage for obfuscation. For named procedures, see Toadskin.

Tbrain[edit]

Tbrain is an extension of the Pbrain programming language. In addition to procedure calls it also adds the option to call procedures on a new thread using ; and to join all threads active of a specific procedure using \. Every thread has its own memory pointer, but the memory itself is shared between threads. The following Tbrain program prints "Hello World" 4 times and waits for all threads to finish before exiting.

(++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.)
;>>>>>>>>>>>>;>>>>>>>>>>>>;>>>>>>>>>>>>;>>>>>>>>>>>>\

Implementations[edit]

External resources[edit]