Pointless

From Esolang
Jump to navigation Jump to search

Pointless is a tape-based esoteric programming language, influenced by brainfuck. There are two versions, Pointless and Pointless!.

Overview

Pointless operates on a tape like that of brainfuck but more precisely defined: the tape is theoretically infinite in the positive direction, and each cell is one byte (with wrapping), like in an 8-byte brainfuck interpreter. The tape uses 0-based indexing, and navigating to a negative cell throws an error. Pointless does have primitive function support, unlike many other esoteric languages. The commands are as follows:

Command Description
< Move the pointer one space to the left.
> Move the pointer one space to the right.
: Move the pointer to the memory cell whose index is equal to the current cell's value.
! Increment the cell under the pointer. This may only run once in a programme; however, this restriction is removed in Pointless!.
= Get the value of the cell whose index is equal to the current cell's value, and change the current cell's value to that.
+ Same as =, but add the value instead of overwriting it.
- Same as =, but subtract the value instead of overwriting it.
[ Jump past the matching ] if the cell whose index is equal to the current cell's value is 0.
] Jump back to the matching [ if the cell whose index is equal to the current cell's value is not 0.
. Output the current cell's value as a character.
, Input a character and save it as the current cell's value.

Anything wrapped in quotes is either a function call or function declaration, depending on whether or not the next non-comment character is {. Braces are used to declare functions, and functions may be declared anywhere in the programme:

>>>>"example function"<<.        Call example function in the middle of a programme
"example function"{[<,]}         Declare example function

Any unrecognized characters outside of quotes are ignored as comments.

Examples

It turns out that Pointless is quite difficult to programme in, even for an esoteric language. One of the difficulties arises from the fact that the effect of most of the commands which change the current cell's value is different depending on the value before the command is executed.

Hello, World!

"setup"                                      Call the setup function
+++++++++++++++++++++++++++++++              Change the current cell to 32 This only works because the cells from 1 to 121 are all 1
[                                            This will loop until cell #114 is equal to 0 because all the cells from 32 to 1 are 0
>                                            Advance the pointer by one
+                                            Add the value of cell #1 (1) to the current value of cell #115
>++>++>+++>+++>+++>+++<<<<<<<-               Continue in a similar vein
]
                   When this loop exits the values will be as follows 
                   0→0; 1 to 113→1; 114→0; 115→33; 116 and 117→65; 118 to 121→97; 122 and up→0;
>-                                           Change #115 to 32
>+++++++.                                    Change #116 to 72 and output it (as the character H)
>++++++++++++++++++++++                      To be honest the rest is pretty simple
>++++.
>+++++++++++..
>++++++++++++++.
<<<<<.>>.>>>.>+++++++++++++++++.<<.<-.<<<+.
"setup"                                         This is the declaration of setup
{
!                                               Change the value of cell #0 to 1;
                      (we can only call this function once but it's fine unless we call setup multiple times)
>+                                              Change the value of cell #1 to the value of cell #0 (1);
>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+
>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+
>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+
>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+
>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+>+
>+>+>+>+>+>                                     Repeat a bunch of times to fill the cells 1 to 121 with 1s
:-                                              Go to the cell #0 and decrease it by the value of the cell #1 (1)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>                          Go to cell #114
}

Computational class

Pointless! is a bounded storage machine, as it could compile to the I/D machine with limited memory access.

I: !
D: :

The original version of Pointless is limited to one use of ! however it is Turing-complete as there exists a translation from Smallfuck. All that is required is that * be replaced with = and [ and ] with =[= and =]= respectively, as well as prepending !>> to the program to set the first two cells to 1 and 0.