Extended Foo

From Esolang
Jump to navigation Jump to search

Extended Foo is a modified version of the original Foo language with new features like nondeterminism, user input and better program flow control. Both Foo and Extended Foo are designed by User:Feky.

Due to the change in the design of the loops, Foo programs are not compatible with Extended Foo and vice versa.

Memory

The memory is organized the same way as in Foo, which means it's represented as an array of cells and each cell holds a positive integer. The size of the cell isn't strictly defined and can be changed. The most common size is 16 bits. Output (except in hex, which is removed), the stack and loops are implemented in the same way.

Syntax

Again, pretty much the same as in Foo, so this will show only the different stuff:

? - Set the current cell to a random value.

~ - Read data from standard input.
    If written as '~i', it will try to convert the input string to a positive integer and set the value of the current cell to it.
    If written as '~c', it will input a string of characters, setting each cell to a different value.

( - The IF statement. If it is followed by a number, it will execute the next action only if the number equals to the current cell.
    If there's no number specified, it will compare the cell to a value popped off the stack. There are other comparisons as well:
	( - if equal
	) - if not equal
	[ - if larger
	] - if smaller


} - Unconditional looping, back to the last '{' symbol on the loop stack.
    The loops work the same way as in Foo, except that they have no conditions.

Note: The '$h' operation is no more. That means, no I/O in hexadecimal.

See also