Alchemy

== Overview ==
Alchemy is an esoteric programming language created by User:EvincarOfAutumn in April 2008.
Each Alchemy program consists of a series of "reactions", which perform arithmetic operations and I/O, numeric line labels, and conditional jumps to those labels. Comments are given in parentheses.
== Elements ==
Variables in Alchemy are called "elements". Elements have the following properties:
* Element names are alphabetic.
* Element names must begin with a capital letter.
* The names of water-soluble elements begin with Aqua.
* The names of dry elements end with ius.
* The names of wet elements end with ium.
* Each element has a "substance number" equal to the sum of the ASCII character values in its identifier.
=== Predefined Elements ===
The following elements will be defined at the start of an Alchemy program, and will have the indicated initial values. This is a work in progress and will arrive later.
== Steps ==
Steps may be given numeric labels with a declaration of the form:
 Step Number:
Where Number is an integer.
The programmer may conditionally jump to a label:
 ElementName? Number
If ElementName is nonzero, then program execution jumps to Step Number.
== Reactions ==
The general syntax of a reaction is:
 ProcessName ElementList (Solvent): ProductName
Where ProcessName is the alchemical process to be performed, ElementList is a list of the names and amounts of the elements used in the reaction, Solvent defines which solvent to use for the reaction, and ProductName indicates the element to which the result of the reaction should be stored.
=== Processes ===
==== I/O ====
Process name	Element effect
Digest 	Inputs a value for each element.
Multiply 	Outputs the value of each element.
==== Arithmetic ====
Process name 	Element Effect
Project 	Calculates the sum of all elements.
Ferment or Putrefy 	Subtracts all following elements from the first.
Fuse 	Calculates the product of all elements.
Calcinate 	Divides the first element by all following.
Cerate 	Decrements the first element and returns it.
Fixate 	Truncates the first element and returns it.
Sublimate 	Calculates the bitwise OR of all elements.
Distill 	Calculates the bitwise AND of all elements.
Filter 	Calculates the bitwise inverse of the first element.
Congel or Coagulate	Calculates the arithmetic mean of all elements.
=== Element Lists ===
An Element List is of the form:
 Number Unit ElementName, Number Unit ElementName, ...
Where Number is an integer number; Unit is dr (drams) for dry elements or oz for wet elements; and ElementName is an identifier.
=== Solvents ===
The general form of a solvent declaration is:
 Number oz SolventName
Where Number is an integer and SolventName is either Water or Alkahest. Water may only be used as a solvent if all of the elements in the reaction are water-soluble. Alkahest is a universal solvent, but it may be used only in an amount equal to its substance number (813) times the number of ingredients in the reaction. If this amount is exceeded by a reaction, then the reaction immediately following must not use Alkahest.
The amount of solvent used for a reaction must exactly be equal to the amount required for the ingredients. Dry ingredients require 1 oz Alkahest or 2 oz Water per dram, and wet ingredients require 2 oz Alkahest or 3 oz Water per ounce.
== Explosions ==
Every error that can occur in a program as a direct result of the programmer's carelessness causes an Explosion. All Explosions are fatal. The interpreter deletes all files in the same folder as any source file that Explodes.
The following Explosions are currently defined:
* Substance Explosion - Element amounts do not produce the same values.
* Insufficient Alkahest Explosion - The reaction attempted to use Alkahest when the supply was depleted.
* Insolubility Explosion - Not all given elements are soluble in water.
* Excessive Solvent Explosion - Too much solvent was supplied for the reaction.
* Insufficient Solvent Explosion - Not enough solvent was supplied for the reaction.
* Ambiguous Step Explosion - Attempted to declare a duplicate line label.
* Undefined Step Explosion - Attempted to jump to a nonexistent line label.
== Examples ==
=== Snippets === 
The following commented snippet computes the product of Mercurius and Saturnium and stores the result in Aquariatus.
 ( Mercurius has a substance number of 959. )
 ( Saturnium has a substance number of 968. )
 ( The least common multiple of 959 and 968 is 928312. )
 ( The amount of Mercurius required is 928312/959 or 968 drams. )
 ( The amount of Saturnium required is 928312/968 or 959 drams. )
 ( Mercurius is dry, so it requires 1 oz Alkahest per dram. )
 ( Saturnium is wet, so it requires 2 oz Alkahest per dram. )
 ( The amount of Alkahest required is 1*959+2*968 or 2895 ounces. )
 ( The amount of Alkahest used is greater than the substance of Alkahest(813), )
 ( times the number of elements (2), so the supply of Alkahest is depleted. )
 ( The product should therefore be water-soluble, )
 ( so the next reaction doesn't try to use Alkahest. )
 
 Fuse 968 dr Mercurius, 959 dr Saturnium (2895 oz Alkahest): Aquariatus
=== Full Examples ===
(I don't have all day!)
== External resources ==
* Alchemy interpreter by User:Shadwick on Bitbucket
Category:Languages
Category:Thematic
Category:Implemented
Category:Unknown computational class
Category:2008