GotoScript

GotoScript is a hardly-esoteric esoteric programming language devised by User:Quito0567 on Nov. 12, 2023. Its control flow consists solely of (conditional) GOTO statements.
== Data types ==
GotoScript supports strings, integers, and floats. Boolean values are represented with 0s (False) and 1s (True).
== Labels ==
All lines containing code must begin with a unique label so that they can be referred to later in the program. Labels may be any data type. For example, in the following line, 'print' is the label:
 'print' PRINT 'Hello, world!'
== Keywords ==
==== Input and output ====
; PRINT : outputs a message to the console.
; PRINTF : outputs a message to the console with variable placeholders surrounded by curly braces.
; INPUT : retrieves user input with an optional prompt.
; CLEAR : clears all output in the console.
==== Control flow ====
; GOTO : jumps to the line with a given label.
; GOTO IF : a GOTO that runs if a given condition is true.
; GOTO ONCE : a GOTO that runs the first time the given condition becomes true.
; GOTO WHEN : a GOTO that runs whenever the given condition becomes true.
; GOTO CATCH : a GOTO that jumps to another line if an error occurs on the first one.
==== Built-in variables ====
; GOTOS : stores the number of GOTOs that have run in the program so far.
; CAUGHT : stores the error stopped by the last GOTO CATCH.
== Operators ==
Operator 	Operation
+ 	addition, concatenation
- 	subtraction, string removal
* 	multiplication, string duplication
/ 	division
// 	floor/integer division
% 	modulo
^ 	exponentiation
:=, +=, -=, *=, /=, //=, %=, ^=	assignment
! 	Logical NOT
︱ 	Logical OR
& 	Logical AND
= 	equality
!=, <, <=, >, >= 	inequality
$ 	containment
== Quitoan notation ==
Quitoan notation is the operator notation utilized in GotoScript, which it is unique to. In Quitoan notation, expressions are written as a series of expressions that build off each other, separated by commas. Previous expressions in the series can be referenced with automatically-assigning variables from lowercase a to z. As such, when declaring one-letter global variable names, it is advised to make them uppercase as to not override these local variables.
=== Benefits ===
Quitoan notation has several advantages over standard infix notation. The most prominent is that, by reducing complex expressions into a list of smaller steps to perform and eliminating parentheses, Quitoan notation is often easier to read and understand. The second is that, with the use of the automatic variables, repeated parts of an expression can be combined. These two advantages are showcased in the below examples:
=== Examples ===
* (2 + 3) * 2 becomes 2 + 3, a * 2.
* ((4 + 4) * (4 + 4 - 2)) ^ 2 becomes 4 + 4, a - 2, a * b, c ^ 2.
* x * (2 - (8/9 ^ n) ^ 2) becomes 8/9 ^ n, 2 - a ^ 2, x * b.
* ((A & B) | (C & D)) & !(E | F) becomes A & B, C & D, E | F, a | b & !c.
== Other stuff ==
* Comments are denoted with a hashtag (#).
* String indexing and slicing are done like in Python.
* Multiple assignments (a := b := c) and chained comparisons (a = b <= c) are supported.
== Turing-completeness ==
GotoScript is almost surely Turing-complete as the Rule 110 automaton could feasibly be written in it. GotoScript possesses all the features required for the task: variables, indexing, conditions, and loops (albeit unconventional ones at that).
== Reviews ==
* "Now this, this is epic." - Quito0567's friend, OhNoman1259
* "Wow." - Quito0567's cousin
== Version history ==
=== Nov. 12 ===
* The first version of GotoScript.
=== Nov. 13 ===
* Added GOTO ONCE and GOTO CATCH statements.
* Added the built-in CAUGHT variable.
* Added the containment operator ($).
=== Nov. 17 === 
* Added the PRINTF (formatted print) command.
=== Nov. 25 ===
* GotoScript switches from Infix to Quitoan notation, which Quito0567 invented earlier that day.
=== Nov. 27 ===
* Added the CLEAR command.
== Example programs ==
=== Cat program ===
 1 PRINT INPUT
=== Looping counter ===
 1 PRINT '*' * GOTOS + '*'
 2 GOTO 1
=== Truth-machine ===
 # Get input
 1 GOTO 4 IF INPUT = 0
 
 # Print 1 infinitely
 2 PRINT 1
 3 GOTO 2
 
 # Print 0
 4 PRINT 0
=== Factorial ===
 # Get input
 1 n := max := INPUT
 
 # Factorial operation
 2 n *= GOTOS + 1
 
 # End loop
 3 GOTO 5 IF GOTOS >= max - 2
 
 # Continue loop
 4 GOTO 2
 
 # Output
 5 PRINT n
=== Print the first n Fibonacci numbers ===
 1 n := INPUT
 2 a := 0
 3 b := 1
 4 c := a + b
 5 a := b
 6 b := c
 7 PRINT b
 8 GOTO 4 IF GOTOS < n - 1
=== FizzBuzz ===
 # Variables
 1 max := 100
 2 n := 0
 3 to_print := ""
 
 # Conditionals
 4 GOTO 8 IF n % 15 = 0
 5 GOTO 9 IF n % 3 = 0
 6 GOTO 10 IF n % 5 = 0
 
 # Print options
 7 to_print := n
 8 to_print := 'FizzBuzz'
 9 to_print := 'Fizz'
 10 to_print := 'Buzz'
 
 # Output
 11 GOTO 12 WHEN to_print != ""
 12 PRINT to_print
 
 # Continue loop
 13 n += 1
 14 GOTO 3
 
 # End loop
 15 GOTO WHEN n > max
=== Deadfish interpreter ===
As shown below, the usage of possible inputs (in this case, Deadfish commands) as labels is a clever way to shorten GotoScript code. It's like match-case in Python or a switch statement in Java.
 # Variables
 1 x := 0
 2 new_x := ""
 
 # Reset accumulator on under/overflow
 3 GOTO 1 IF x < 0 | x = 256
 
 # Get input
 4 GOTO INPUT '>> ' CATCH 5
 
 # Invalid input
 5 PRINT 'Invalid command.'
 
 # Increment
 'i' new_x := x + 1
 
 # Decrement
 'd' new_x := x - 1
 
 # Square
 's' new_x := x * x
 
 # Output
 'o' PRINT x
 6 GOTO 4
 
 # Loop back
 7 GOTO 2 WHEN new_x != ""
Category:Languages
Category:2023
Category:High-level
Category:Unimplemented
Category:Turing complete