User:Darkgamma/SB

Sandbox. Place for defining a language, I guess. That's what I joined for anyway

Language idea
Idea: a language that is somewhat medieval-themed. It is supposed to be a structured/imperative programming language with supports for subroutines, loops, if-then-else, but also with lots of possibilities for spaghetti code and lots of needless stuff. It has some properties of an object-oriented language but is not an OOPL per se.

Variable
In the language, variables are basically objects with some properties: it has a value, a parent and an occupation, along with some additional properties.

All "root" variables usually are declared at start in a variable block of code. These root variables are variables without parents. No variable without a parent can be defined after the variable block. Variables are not created dynamically and every variable must be declared. A few special exceptions exist

To make a root variable, you use the "BRING" command. Spawning children is done with the "SPAWN FROM" command.
 * BRING X - creates the X variable
 * SPAWN X FROM Y - creates the X variable and makes variable Y its parent variable

The "SPAWN FROM" command can be used at any time while "BRING" cannot.

A variable can be forbidden from having a specific value by "BAR FROM" and "LET BE" commands.
 * BAR X FROM Y - forbids variable X from having the value of variable Y
 * BAR X BE Y - synonymous with above
 * LET X BE Y - allows variable X to have the value of variable Y if it has been previously forbidden

Variables can be changed to constants and back. This is done with the "FREEZE" and "THAW" commands.
 * FREEZE X - freezes variable X, barring it from being changed later on
 * THAW X - unfreezes variable X, removes 1/10 from X

Additional commands allow for global freezing and thawing. They are "WINTER" and "SUMMER"
 * WINTER - freezes every variable
 * SUMMER - thaws every variable, removes 1/10 from each variable

The "BREED WITH" command works similarly to the "SPAWN FROM" command, except it also gives a value and takes two variables.
 * BREED X WITH Y - takes 1/2 from variable X and 1/2 from variable Y and adds it to a new variable that becomes a child of the variable X. Goes with "NAME"
 * NAME X - names the new variable created from the commands that make variables from other variables as "X"; must be used after "BREED WITH". If not used, the new variable is destroyed and the value goes to waste

Some occupations are assigned via the "MAKE" command (with some synonyms).
 * CROWN X - gives variable X the occupation of "KING". There can be only one king.
 * MAKE X KING - synonymous with above
 * MAKE X EXECUTIONER - gives variable X the occupation of "EXECUTIONER"
 * MAKE X PRIEST - gives variable X the occupation of "PRIEST"
 * MAKE X JUDGE - gives variable X the occupation of "JUDGE"
 * MAKE X TEACHER - gives variable X the occupation of "TEACHER"

Some commands deal with some occupations in specific ways.
 * ABDICATE KING - divides value of KING across all his children, eldest child becomes KING, old KING loses occupation "KING"
 * REGICIDE - destroys KING, divides value of KING across all his children, eldest child becomes KING
 * X DEPOSE KING - all the value of KING goes to variable X; KING is destroyed and X is given the occupation of "KING"

Some commands deal with value copying.
 * CLONE X - creates a variable whose value is identical to X. Goes with "NAME".
 * CLONE X IN Y - creates a variable Y whose value is identical to X. Bypasses "NAME".
 * MAKE X BE Y - makes the value of variable X be equal to variable Y

Special occupations and corresponding commands:
 * X ENSLAVE Y - makes variable X the child of variable Y and gives X the occupation of "SLAVE". All the value of X is transferred to Y
 * FREE X - makes variable X a free variable and makes it lose the occupation "SLAVE".
 * X TEACH Y - makes variable Y the child of variable X, gives Y the occupation of "SCRIBE". Only a "TEACHER" variable can be X. Y cannot have any occupation other than "SLAVE"

There are also some special variables:
 * SET TAXES TO X - sets the value of taxes to X
 * SET TITHES TO X - sets the value of tithes to X