Forget

From Esolang
Jump to navigation Jump to search

Forget

Forget is a stack-based language where pointers are poisonous and the interpreter doesn't do a good job of remembering non-constant values

Syntax

Instructions are separated by semicolons.

push (number) writes the given decimal integer to memory and pushes a pointer to the stack
pop pops a pointer from the stack so it can be used
in reads a single character from standard input, stores it in memory, and pushes the corresponding pointer to the stack
read (address) loads the value stored at the given address so it can be used.
write (address) (number) writes the given number to the memory at the given address
cleanse (pointer) makes the given pointer non-poisonous. If no pointer is provided, the one on the top of the stack is cleansed
const (address) (number) same as write, but is immutable and can only be used before any other instruction is processed
out prints the value on top of the stack as a character
dump clears the stack, printing each value as a character
while (address) executes the code in between this instruction and the corresponding end instruction while the value at the given address is greater than 0
hasin a special variant of while that loops while data is available from standard input
end marks the end of a while block
add (value1) (value2) adds the arguments (pointers or numbers) and pushes the result to the stack. If an argument is missing, the value on the top of the stack is used
sub (value1) (value2) same as add, but subtracts instead

Errors

Any attempt to deference a poisoned pointer will result in a segmentation fault

Reading an unallocated address has a chance of either segfaulting or returning garbage data

Examples

Here is a computer-generated Hello, World! program written in Forget:

const 0x0 10;
const 0x1 33;
const 0x2 100;
const 0x3 108;
const 0x4 114;
const 0x5 111;
const 0x6 87;
const 0x7 32;
const 0x8 44;
const 0x9 111;
const 0xa 108;
const 0xb 108;
const 0xc 101;
const 0xd 72;
cleanse 0xd;pop;out;
cleanse 0xc;pop;out;
cleanse 0xb;pop;out;
cleanse 0xa;pop;out;
cleanse 0x9;pop;out;
cleanse 0x8;pop;out;
cleanse 0x7;pop;out;
cleanse 0x6;pop;out;
cleanse 0x5;pop;out;
cleanse 0x4;pop;out;
cleanse 0x3;pop;out;
cleanse 0x2;pop;out;
cleanse 0x1;pop;out;
cleanse 0x0;pop;out;

This is a cat program written in Forget. Terminates after a newline:

in;
cleanse;
out;
hasin;
in;
cleanse;
out;
end;

Resources

Forget interpreter (written in Java)