Brace For Impact

From Esolang
Jump to: navigation, search

Brace For Impact is a Stack-based esoteric programming language made by Areallycoolusername. It has features derived from Lisp,though it is not a Lisp Derivative. All programs made in this language have a tendency to crash during execution.

Specification

Contrary to what you might think, this isn't a joke language. It was made as an experiment to better understand how memory is allocated and used. There are 10 commands in Brace For Impact. Each of these commands are used to manipulate data in the stack, output things, and perform loops.

Command Function
(q#) Starts If statement
(w&) Starts While loop
(e%) Starts Else body
(r$) Starts For loop
(t@) Declares variable
(y~) Prompts user for input, and places that input at the top of the stack
(a') Pops value at the top of the stack
(s;) Pushes value at the top of the stack
(d.) Switches value at the top of the stack, with the value below it
(f=) Outputs value at the top of the stack.

Brace For Impact has as a Stack with infinite length. Perfect for being a catalyst for unresponsive programs. All commands are surrounded in parentheses, similar to lisp. However, the arguments aren't. This language is also the first language I made that can implement a Truth-machine.

(a'),(s;),(d.), (f=), and (y~)

These 5 commands manipulate the stack in some way. The push command, "(s;)", pushes the character value in front of the command onto the stack. The Switch command, "(d.)", can only be used when there is at least two values in the stack. It switches the value on the top of the stack, with the value directly below it. The Output command, "(f=)", outputs the value at the top of the stack. The Pop command, "(a')", is self-explanatory. The input command, "(y~)", prompts the user for input, and places the value received at the top of the stack. Here is an example using all 5 commands.

(s;) )
(s;) x
(s;) f
(s;) (
(s;) L
(a')
(y~)
(f=)
(f=)
(f=)
(f=)
(f=)

This program pushes, ")", "x", "f","(", and "L". L is at the top of the stack. The pop command is called, and L is removed from the stack. The "(" , is at the top of the stack now. The input command is called, and the user is prompted for input. Say that the value entered is, "Oof ". Oof is at the top of the stack now. The switch command is used to switch "Oof " with the value below it, "(". Then, "(", "Oof ", "f", "x", and ")" is printed to the screen. This looks like, (Oof fx)

(q#), (w&), (e%), (r$), and (t@)

These five commands deal with control flow. The if statement, (q#), must be followed by a condition, and that condition, just be followed by the keyword, (j^), followed, by the code you want executed. The else command, (e%), can be used after The if statement, to declare want is to be done if The condition is not met. The while command, (w&), will start a while loop. It must be followed by a condition, the keyword, and the code you want executed. Variables are declared with the variable command, (t@). This is then followed by the variable name, the keyword, and the value of the variable. The for loop, (r$), must have a variable declaration in its condition, followed by The condition itself, and what you want done to the variable. Here is an example using all 5 commands.

(t@)foo(j^)0
(q#)foo < 100(j^)
     (w&)foo < 100(j^)
        foo(j^)foo + 1
        (s;) foo
        (f=)
(r$)(t@)bar(j^)99(j^)bar > 0(j^)bar(j^)bar - 1(j^)
    (s;)bar
    (f=)  

This program declared the variable foo with value 1. It then checks if foo is less than 100. It is, so it increments foo by 1, pushes it to the stack, and prints it, while foo is less than 100. It then declares a for loop with the variable bar, which has a valid of 99. It checks if bar is more than 0, and if it is, it decrements bar by 1. It then pushes bar to the stack, and prints it.

Turing complete Proof

Brace For Impact has an unbounded stack, so an infinite amount of values can be given and manipulated. We can prove this by using a Sequential tag system. If we repeat the program:

(s;)99

Infinitely, the language would never stop pushing 99 onto the stack, as the stack is unbounded. This proves Turing Completeness. Here is a Sequential Tag System in Brace For Impact.

(t@)i(j^)99
(w&)i = 99(j^)
   (s;)99

It pushes 99 to the stack infinitely. The interpreter will never stop, an thus will enter an infinite loop.

Examples

Brace For Impact can implement many things, including but not limited to: a hello world program, a 99 bottles program,and a truth machine. Here are some examples of Brace For Impacts capabilities.

Hello World Program

Brace For Impact skips spaces, so instead of the initial space used in usual hello world programs, the underscore is used.

(s;) H
(f=)
(s;) e
(f=)
(s;) l
(f=)
(f=)
(s;) o
(f=)
(s;) ,
(f=)
(s;) _
(f=)
(s;) w
(f=)
(s;) o
(f=)
(s;) r
(f=)
(s;) l
(f=)
(s;) d
(f=)
(s;) !
(f=)

Truth-machine

(t@)in(j^)(y~)
(q#)in = 0(j^)
   (f=)
(e%)
   (t@)out(j^)1
   (w&)out = 1(j^)
      (s;)out
      (f=)