Pancode - Commands - IO

The following commands deal with input/output. Note that, in the online interactive console, input is provided through an explicit "Input" textbox and output is printed below the program.

Pretty Print (.)

Pops one value from the stack and pretty-prints it to output.

Read Integer (,)

Reads a valid integer from input and pushes it onto the stack. Returns ฮต if input is empty or there is no valid integer to consume.

Read Character (๐Ÿ“œ)

Reads a single character from input and pushes it onto the stack as a single-character string. Returns ฮต if input is empty.

Read Line (๐Ÿ“–)

Reads from input until it encounters a newline or the end of input, pushing the resulting string. Returns ฮต if input is empty. Note that the newline is included in the resulting string and can be removed with Chomp (๐Ÿด)

Read All (๐Ÿ“š)

Reads all remaining input and pushes it onto the stack as a string. If there's no input, returns ฮต.

Print Whole Stack (๐Ÿ™‹)

Print every element of the stack, from bottom to top. Does not modify the stack in any way. The exact format of the text printed by this command is subject to change at any time, as it is mainly intended for debugging use.

Panic (๐Ÿ˜ฑ)

Pops one value from the stack and halts the program with an error. The error will include, in some form, the value which was popped.

Handle Error (๐Ÿ™)

Takes two functions. Invokes the first function. If it returns normally, then control proceeds as normal. If it throws an error, then the second function will be called with the original call stack and the error itself.

Note that, in the case of error, the call stack is rolled back to its state at the time the ๐Ÿ™ command was invoked.

Example:

1 [ 2 "error" ๐Ÿ˜ฑ ] [ % . ] ๐Ÿ™ ยซ Prints 1, not 2 ยป
Documentation Index