|Computational class||Turing complete|
Vitsy programs are are aware of any of the following things:
- The main program (this is the program that you run) and the code thereof.
- The data held in
- The .
- They may also be aware of other program files. These programs are loaded dynamically, allowing for programs to be changed mid-execution, if need be.
All Vitsy programs are composed of UTF-8 text files (extension optional, typically .vt) containing commands in the Vitsy language. A Vitsy program is organized into four main components:
Methods in Vitsy are separated by newlines and indexed in array format for access. When a Vitsy program is run, the first line (or the main method) is executed. Other methods will not be run unless specified by the method command with that index of the methods. Methods retain the current state of thewhen called, as well as knowing the current values for the and the . Methods in other programs may be called through the class method command, which will call the specified index of the methods in the specified index of the s. Method calling may be recursive.
Blocks are sections of code that are surrounded by
[ (the begin block command) and
] (the end block command) commands which designate this section of code to act as though it was a single command. All blocks will continue until closed by the end block command, meaning that if the block is not terminated before the end of the
Conditional blocks are blocks preceded by the if or if not commands. If the condition for the if statement is met, the block will be executed, otherwise, it will not. Conditional blocks may not be broken out of as for loops are broken from; calling the end command inside of a conditional block will cause the previous block layer to be broken out of (or, if there are no higher levels of block, the currentwill terminate).
Repeat blocks are preceded by the repeat command and are executed as though it were a single instruction, repeating the contents of the loop as many times as would be repeated for a single command. Repeat blocks may be broken out of with the end command.
If none of the previous types of blocks are found, the block is treated as a loop block, which will loop infinitely unless:
- broken out of with the end command
- the integer value of the top item of the stack is zero at the end of the block
Commands are executed one at a time (unthreaded) and may affect the current state of STDIN, STDOUT, the stack, local files (disabled in safe mode), and the system (via shell) (disabled in safe mode). A list of commands is provided below.
||if not||Conditional execution of the next command; if the integer value top item of the stack is not equal to zero, then the next command in thewill be executed. Otherwise, it will not. If the if not command is followed by a opening square bracket, all commands within the that pair of square brackets will be conditionally executed with the same conditions as above.|
||if||Conditional execution of the next command; if the integer value top item of the stack is equal to zero, then the next command in thewill be executed. Otherwise, it will not. If the if command is followed by a opening square bracket, all commands within the that pair of square brackets will be conditionally executed with the same conditions as above.|
||begin block||Begins aof code. This of code will be treated differently according to the command previous to the begin block command. If the either the if or if not command is the previous command, it will conditionally execute the once. If the repeat command is the previous command, it will execute as many times as the top item of the stack specifies (or until broken by the end command). Otherwise, it will be executed until the top item of the stack is zero when the end block command is called (or until broken by the end command).|
||end block||Ends aof code. This is treated as a non-operational character if we are not currently in a of code. If the is an infinite||On empty stacks, the loop causes an ArrayOutOfBoundsException.|
||repeat||Repeats the next command oras many times as specified by the integer value of the top item of the stack. May be broken out of with the end command.|
||end||Generic end command. Not to be confused with
||exit||Generic exit command. The program is halted immediately with an error code as the integer representation of the top item of the stack modulo 256.|
||teleport||Teleport to the index of commands as specified by the integer value of the top item of the stack. This is mainly unsupported, and likely to be removed in future versions.|
||move left||Change the direction of the instruction pointer's movement towards the left. Moving left also informs the interpreter to wrap around to the end of thewhen reaching the first command in the .|
||move right||Change the direction of the instruction pointer's movement towards the right. While moving right,s will finish and return back to the previous (or terminate the program if on the main|
||toggle quote||Toggle capturing of instructions as strings. As each instruction is passed, it's UTF-8 value is pushed to the current. The quote does not end until locating another quote, wrapping around the line if it must.|
||method||Pop the integer value of the top item of the currentas n, go to index n of the s and execute it. When it finishes, return to this point in the code and continue execution of this line.|
||input||Pops the final item of theand pushes it to the top of the current as its decimal value. If there are no values to be popped from the|
||input length||Pushes the current length of theto the top of the current as its decimal value.|
||length||Pushes the current length of the currentto the top of the current as its decimal value.|
||get all input||Pops all items off theand pushes them in top-access order to the . If there are no values to be popped from the|
||output the stack||Pops all items off of the currentand pushes them to STDOUT in top-access order with ISO-8859-1 encoding.|
||output as char||Pops the top item off of the currentand pushes it to STDOUT in ISO-8859-1 encoding.|
||output as number||Pops the top item off of the currentand pushes it to STDOUT as a float value, using the greatest precision available.|
||get STDIN||Grabs a line from STDIN and evaluates it. If it is parseable as a decimal, it will push the decimal value to them current. Otherwise, it will parse it as a string, pushing each character to the current in top-access order to the .|
||single switch||Switch the top two items of the current. If there is only one item on said stack, push a zero to accommodate.|
||multi switch||Pop the top value off the currentas n, then rotate the top n items of the stack to the right. If there aren't enough items in the stack, push zeroes to accommodate.||Zero-filling for stack accommodation is inaccurate and throws values around wildly. Do not use multi switch on a stack with fewer values than specified with n.|
||rotate right||Rotate the currentin a fashion that moves the bottom value to the top without changing the order of the other values.||This will change the current|
||rotate left||Rotate the currentin a fashion that moves the top value to the bottom without changing the order of the other values.||This will change the current|
||reverse||Flip the entire current. This causes the top item to be on the bottom and vice versa, changing the values in between in the same fashion.|
||part||Pop the top value of the currentas n, then push the value of the nth item of said stack (where the top item is 1, the second to top is two, etc)|
||duplicate||Duplicate the top value of the currentand push it to said stack.|
||remove||Pop the top value of the currentand discard it.|
||object||Pop the currentoff of the stack and store it in the next command's string value. Note that the next instruction character should be non-operational, as popping stacks into characters that are defined for other methods is unsupported. This is only necessary to be called the first time you declare the instruction character; after declaration, the character will tell the interpreter to dump the to the . If there is no to dump being held by the|
||new stack||Push an emptyto the and move to it.|
||remove stack||Pop and discard the current|
||clone stack||Deep clone the current stack, retaining its values, and then push it to the|
||right stack||Move from the currentto the an index one greater than the current. If moving to a stack that does not exist, the will be set to the 0th index of s.|
||left stack||Move from the currentto the an index one less than the current. If moving to a stack that does not exist, the will be set to the final index of s.|
||flatten||Join the top two stacks together, concatenating the values of the currentto the end of the stack to the left of the current stack.||If there is only one|
||stack count||Push the number of stacks to the.|
||temporary variable||If theis currently empty, capture the top item of the and save it in the slot. If the slot has already been taken, pop it from the slot and push it to the . This value transfers over s and classes.|
||final variable||If theis currently empty, capture the top item of the and save it in the slot. If the slot has already been taken, peek it from the slot and push it to the . This value transfers over s and classes.|
||sine||Pop the top item of the stack as n, push sine of n (as a radian) to the current.||Uses 100 point precision approximation for pi, which will cause some rounding error.|
||arcsine||Pop the top item of the stack as n, push arcsine of n to the current(as a radian).||Limited to Integer.MAX_VALUE|
||tangent||Pop the top item of the stack as n, push tangent of n (as a radian) to the current.||Uses 100 point precision approximation for pi, which will cause some rounding error.|
||arctangent||Pop the top item of the stack as n, push arctangent of n to the current(as a radian).||Limited to Integer.MAX_VALUE|
||cosine||Pop the top item of the stack as n, push cosine of n (as a radian) to the current.||Uses 100 point precision approximation for pi, which will cause some rounding error.|
||arccosine||Pop the top item of the stack as n, push arccosine of n to the current(as a radian).||Limited to Integer.MAX_VALUE|
||pi||Push a decimal approximation of pi to the current.|
||e||Push a decimal approximation of Euler's constant to the current.|
||log||Pop the second to top item of the currentas n, pop the top item of said stack as o, push logarithm base o of n.||Float point precision problems.|
||random||Pop the top item of the currentas n, push a random decimal between 0 and n to the stack.||Not uniformly random.|
||add||Pop the top item of the currentas n, pop the second to top item of the same stack as o, push the sum of n and o to the same stack.|
||subtract||Pop the top item of the currentas n, pop the second to top item of the same stack as o, push o minus n to the same stack.|
||multiply||Pop the top item of the currentas n, pop the second to top item of the same stack as o, push the product of n and o to the same stack.|
||divide||Pop the top item of the currentas n, pop the second to top item of the same stack as o, push n divided by o to the same stack.||Float point error problems with infinite repetitions.|
||power||Pop the top item of the currentas n, pop the second to top item of the same stack as o, push o to the power of n to the same stack.||Float point error problems, restricted to primitive double precision/size.|
||equals||Pops the top two items of the currentand compares them. If they are equal, push 0. Else, push 1. This is mostly unsupported (as the subtract command can do this more efficiently) and may be removed in future versions.|
||modulo||Pop the top item of the currentas n, pop the second to top item of the same stack as o, push the remainder of n divided by o to the same stack.|
||truncate||Replace the top item of the currentwith its integer value.|
||factorize||Pop the top item of the currentas n, push its factors to the same stack.|
||prime||Replace the top item of the stack with 1 if it is prime, 0 if it is not.|
||range||Pop the top item of the currentas n, pop the second to top item of the same stack as o, push the range between o and n to the same stack, retaining order.|
|Separate Program Management||Please see the next section for more information.|
||program method||Pop the top item of the currentas n, pop the second to top item of the same stack as o, load index o of the s and execute its nth index of code. This is disabled in safe mode.|
||short program method||Pop the top item of the currentas n and load the program as declared in the and execute its nth index of code. This is disabled in safe mode.|
||uses count||Push the number of validto the current . This is disabled in safe mode.|
||use name||Pop the top item of the currentas n, get the name of index n of the s and push it to the same stack input style, with special cases -2 requesting the name of the ext declared program and -1 getting the name of the current program. This value changes according to the currently executing program.|
||wait||Pop the top item of the currentas n and wait n seconds before preceding onto the next command.|
||file||Pop the entire currentand use its name as though it was a file name. If the file exists, read its entire contents and push them in top-access format to the stack.|
||write||Pop the entire currentas n, pop the entire second as o. Use n as a file name, then write the contents of o to the file.|
||shell||Pop the entire currentas n and execute it as though it was a shell command..|
use and ext Declarations
use and ext declarations exist solely for the purposes of callings from other programs from a Vitsy program. These declarations always appear at the end of a file, and an example can be found below.
0K00k ;e program2 ;u program3
In this program, I first push 0 to the current
Similarly, we declare use files with
;u. In commands 3 through 5, we push 2 zeroes, then call
k, which executes a in the specified declaration of use files. With
00k, I call the 0th index of use declarations (program3's) 0th index of s. Therefore, we have executed the main Vitsy of program3.
Data is stored in various locations, some of which are read-only, some of which are neither readable nor writable until active, and some of which are readable and writeable immediately. Most data structures are
Vitsy uses multiple stacks, some of which are multi-layered and contain different values. Details for each stack type are below.
Vitsy is aware of all data contained in the program stack. The program stack is toroidal and consists of multiples. There is only one program stack per instance of Vitsy, and it may not be destroyed, but it may be modified through commands found in the Data section of the . The program stack is originally instantiated with an empty on it.
Decimal Stacks are stacks of arbitrarily large decimal values. Vitsy interacts mostly with this form of stack, and all mathematical operations are executed with values found on this stack. These stacks are toroidal and there may be many decimal stacks per program stack. Decimal stacks may be destroyed, created, and modified within thethrough commands found in the Data section of the . Each decimal stack is instantiated empty unless it is a clone of another stack.
String input to any Vitsy program via command line arguments which cannot be parsed as a double are placed onto the input stack. The input stack is top-access only and may only be popped from. Commands which interact with the input stack may be found under the Data section of the.
The method stack is a trace to the currently accessedvia all the previous s (Java style). The method stack is wholly inaccessible for information access, and is used solely for the purposes of tracing back to the place where each was called. There is only one method stack per Vitsy instance which cannot be destroyed or modified in any fashion. The method stack is instantiated with the initial value of the main of the main program file.
The class stack is a trace to the currently access program file and is closely related to the
There are three different variable types in Vitsy - a
The final variable may be called by the final variable command under the Data section of the. When the final variable is first called, it captures the top value of the current and retains it permanently. Any following calls to it will push its value to the current . The final variable's value may not be dumped at any point and said final variable is passed through calls and separate program calls.
The temporary variable may be called by the temporary variable command under the Data section of the. When the temporary variable is called, it will follow one of the two following behaviors:
- If the temporary variable does not currently have a value assigned to it, it will capture the top value of the current and save it for later use.
- If the temporary variable does currently have a value assigned to it, it will dump the value to the current and clear its value.
The temporary variable's value may be dumped when the temporary variable command is called and said temporary variable is passed throughcalls and separate program calls.
Objects ares that have been captured and assigned to a specific character in the instructions. An object must be declared with the object command, which declares the following character as an object character (if it does not already have a meaning through commands) and promptly captures the current stack and pushes it to the object. When the declared object character is called again, it will follow one of the two following behaviors:
- If the object does not currently have a stack assigned to it, it will capture the current save it for later use.
- If the object does currently have a stack assigned to it, it will dump the stack to the
An example, as I realize this is difficult to follow:
1234oj jN j
First, we push 1, 2, 3, and 4 to the current
j (which does not have a command meaning) as an object, grabbing the current and assigning the object called
j's value to said . (There are now no stacks in the .) I now call
j again, pushing the found in
j to the . I then pop the top value and output it as a number, pushing 4 to STDOUT. I now only have 1, 2, and 3 on the stack, which I then capture again by calling
The objects's stack may be dumped when its declared character is called and the declared object is passed throughcalls and separate program calls.
Although not a data structure necessarily owned by the Vitsy instance, STDIN acts similarly to the(but not exactly) in that each line is a separate item and all items of each line are pushed to the stack, evaluating as a decimal when possible. Calling for STDIN while executing through a command line causes the program to halt until a newline is read from the command line.
Input and output is handled in very specific ways in Vitsy. All manners in which input is accepted or output is pushed may be found below.
Command Line Arguments
Command line arguments are accepted as a form of input for Vitsy. If all command line arguments are parseable as decimals, their values are pushed onto the initial. Otherwise, all of the command line arguments are joined with a space and pushed onto the .
Input through standard input must be explicitly requested by the Vitsy program. When being called via the STDIN command (as found in the Data section of the
STDOUT is the only form of output used by a given Vitsy instance for normal output types. See the Data section of thefor how data is output to STDOUT when calling various commands.
STDERR is only output to whenever an error is thrown, showing information about the error and what caused it. Vitsy cannot output to STDERR without throwing an error.
Since quotes push items to the stack in the order in which it encounters them, the string must be pushed in reverse to allow the top-access-only outputting
Z command to output everything in the right order.
Quotes wrap around a line, meaning that, with this code, we can capture all elements of the code, then reverse the stack (for order) and push the character value for
' and output everything. This is a true quine.
- Vitsy comes from a mispronunciation of the first three characters in VTCAKAVSMoACE.
- Vitsy is also referred to as
- Vitsy is also occasionally used throughout VTCAKAVSMoACE's school by Computer Science teachers for quick calculations due to its stack-based nature and simple-to-use polish notation.
- This wiki page for Vitsy is larger in byte count than the entire compiled Vitsy jar.