Con-Text

Con-Text is an esoteric programming language created in 2004 created by User:Sphen lee. It is equivalent to C/C++ however it relies on context so much that it can be impossible to determine what a line does without looking at the entire program.

Syntax
Any line beginning with a single # is a declaration. Simple variables are terminated by a newline; arrays are followed by a list of dimensions separated by hashes; functions are followed by a list of parameters separated by hashes. All primitive variables are integers. The type of an array, function, or parameter defaults to integer, unless a class is specified (see below). Characters use C-style character literals (eg. 'a') and are stored in integers. Strings are C-style (eg. "abc") and are stored in integer arrays.

Lines beginning without a hash are statements (usually).

After declaring a function you have to implement it. Lines beginning with double hash implement functions (except ##start which is the program entry point). Assigning a value to the name of a function from within that function returns that value from the function (sounds complicated but it's the same as QBasic). Calling a function from within that function however is a recursive call. Functions can be overloaded on the number and type of arguments.

(body of function here) func #expression (returns a value) &#
 * 1) func #param (declare the function)
 * 2) func (implement the function)

An 'if' statement is created by placing an expression after an ampersand, if the condition is non-zero the body of the statement is executed (the body is terminated by "&#").

& #condition (body of 'if' statement here) &#

A While statement is created similarly, except that it is terminated by "&" instead.

Exception Handling
An expression can be thrown by following it with &. A try block looks like an if statement with no condition. Following this is a series of catch blocks, which look like declarations of the type of the value to be caught. Each catch block ends with &#. The first non-declaration marks the end of the catch statements (this implies that you cannot declare a variable directly after a catch block).

(block to try) 12& (throw integer 12) &#  (body of catch) &#  (body of catch) &# func #param (non-declaration, end of catch blocks)
 * 1) (try)
 * 1) x (catch an integer, call it x)
 * 1) Exception #e (catch an Exception object, call it e)

Object Orientation
To declare a class use #class-name # (newline). The body of the class follows consisting of variable and function declarations. Constructors are not supported (use factory functions instead). The class body ends with &#. To access members of an object use object #member. To declare an instance of a class use #class-name #object name at any place where an ordinary identifier could be used. For example

#x #y #normalise #dummy (dummy parameter to make a function) #getLength #dummy &# v #x #1 (v.x = 1) print #v #getLength #null ( print(v.getLength(null)) )
 * 1) Vector2D#
 * 1) Vector2D #v (create a Vector2D called v)

To implement a member function of a class (a method) used this syntax: ##class name #function name. For example: x #div #x #getLength #null y #div #y #getLength #null &#
 * 1) Vector2D #normalise (implements Vector2D's normalise method)

Sample Program
Here is a sample program that calculates one root of a quadratic equation. (Comments are in parentheses)

#dis dis #sub #mult #b #b #mult #mult #4 #a #c & #gte #dis #0 (an 'if' statement) root #div #sub #neg #b #sqrt #dis #mult #2 #a &#  dis & (throws the discriminant because it was negative) &#  #x x #root #1 #neg #2 #4 (root of x^2 - 2x + 4 == 0) &#
 * 1) root #a #b #c
 * 2) root
 * 1) start

Implementation
Unfortunately no interpreter or compiler exists at the moment, as i am unable to create a parser to parse this horrendous language.