*lang

From Esolang
Jump to navigation Jump to search

*lang (pronounced pointerlang) is an esoteric programming language invented by User:DigitalDetective47 which can only store pointers.

Program Structure

Programs in *lang are run line‐by‐line. Each statement ends with a semicolon; anything after a semicolon until the end of the line is treated as a comment. All line initial whitespace (not including line breaks) is ignored.

Syntax

To declare a new pointer and assign it to a variable, use new *name;. Asterisks, ampersands, equals signs, and semicolons are not allowed in variable names. Pointers created in the way are self‐referential. Variables are assigned by reference, meaning that multiple variables can hold the same pointer. Assignment can be done as expected: b = a; will set b to the same pointer as a. Variables do not need to be declared before assignment. Pointers can be dereferenced by prepending a * to their name (or expression). For these primative pointers this has no effect, but it will matter later. Prefixing an expression with an & will yield a new pointer which points at the pointer in the expression. This cannot be used on the left side of an assignment expression. For flow control, there is the back expression; statement. The expression provided is evaluated, then execution continues on the line after that pointer was last dereferenced. This jumps to after the pointer is defined if it has not been dereferenced yet. out expression; evaluates the same way as back expression;, but instead of jumping to the line after the dereference, it prints the ASCII character corresponding to the line number modulo 128.

Examples

Hello, world!

new *_;






























new * ;
new *!;










new *,;



























new *H;



























new *d;
new *e;






new *l;


new *o;


new *r;




new *w;
out H;
out e;
out l;
out l;
out o;
out ,;
out  ;
out w;
out o;
out r;
out l;
out d;
out !;

As you can see, outputting text in this language is quite painful.

Infinite loop

A looping program is thankfully easier.

new *start;
back start;

Truth-machine

As *lang has no input, the value used must be specified within the code itself.

new *zero;
new *one;
input = input;
new *nil;
*input = nil; Makes the input value not recursive










































*zero = *zero; Wait for the digits 0 and 1
*one = *one;
out input;
back *one; Only allow the program to exit if the input was not one

Implementations