Point

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.
Point
Paradigm(s) imperative
Designed by Unlimiter
Appeared in 2019
Memory system stack-based
Computational class Turing complete
Reference implementation Unimplemented
File extension(s) .pnt

Point is a stack-based esoteric programming language, initially inspired by Befunge and Glass.

Overview

As from version 0.0.1, a Point program executes instructions on a stack. The stack can contain only integers, which can be used to represent both integers and ASCII characters. All instructions are characters. Some of them depend on others to complete their tasks, like ( and ).

Instructions

Instruction Description
0..9 Push digit as an integer onto stack if not scanning integer.
( Enable integer scanning.
) Disable integer scanning.
" Toggle string scanning; if toggled off, push 0.
[ Enable loop scanning.
] Disable loop scanning, and start scanned loop.
+ Pop top two items from stack. Add them. Push result onto stack.
- Pop top two items from stack. Subtract the first one from the the second one. Push result onto stack.
* Pop top two items from stack. Multiply them. Push result onto stack.
/ Pop top two items from stack. Divide the second one by the the first one. Push result onto stack.
% Pop top two items from stack. Divide the second one by the first one. Push remainder onto stack.
^ Discard top item from stack.
= Duplicate top item of stack.
~ Swap top two items of stack.
> Rotate stack to the right.
< Rotate stack to the left.
$ Clear stack.
# Push size of stack.
? Pop item from stack. If its value is zero, push 1, otherwise push 0.
. Pop item from stack and output it as an ASCII character.
: Pop item from stack and output it as an integer.
, Push item from input as an ASCII character onto stack.
; Push item from input as an integer onto stack.
& Exit program.

In-depth

( enables number scanning. When it's enabled, every scanned digit gets pushed onto the stack, then multiplied by 10 and added to the next digit (if there is one) before .. All that before ) which disables number scanning.

" enables string scanning. When it's enabled, all scanned characters get pushed onto the stack in reverse (unlike Befunge, ugh) before ", which disables string scanning. When string scanning is disabled, 0 gets pushed onto the stack, to indicate the end of the string (which is just characters followed by 0; possibly just 0).

[ enables loop scanning. When it's enabled, every scanned character gets executed as an instruction from the start of the loop, until the top item of the stack is not null, then that top item is discarded (popped without use). ] disables loop scanning.

Other instructions are self-explanatory from the table above.

Examples

Hello, world!

"Hello, Point!"[.]

Note that [.] recursively pops and prints the top item (which is a character pushed by scanning the string "Hello, Point!") as an ASCII character until it's 0, which at that point gets discarded.

Countdown

(10)[=:1-" "[.]]

Here, 10 is the number which will be decremented until reaching 1.

Counting up

0=[^=:1+=(10)~-1+" "[.]]

And here, 10 is the number which will be counted to, starting from 0.