Dumbell

The Dependency Based Language with Definition


Syntactic Details

Much like Python Dumbell requires an intended structure. Indentation must be consistent between tabs and spaces, and within a certain scope must be consistent as well.


Data Types

Integers, floating point numbers, strings, and booleans are all immutable as they are in Python. More complicated data structures, such as lists, are mutable and are passed by reference.

Integers

32-bit values that are immutable. These are defined by any number that does not have a "." somewhere.

Floating Points

64-bit values that are immutable. These are defined by a number with a "." somewhere. However, floating point numbers must start with a digit. A value .42 will cause an error.

Strings

Immutable values that are defined by being placed in either a pair of double quote, "Hello World", or single quotes, 'Hello World'. Special escaped characters are the "\n", "\t" and "\\"

Booleans

Values that are defined as true and false.

Lists

A structure defined by comma separated values within two square brackets: [1, 2, 3].


Operators

Arithmetic

The arithmetic operators are addition (+), subtraction (-), division (/), multiplication (*), modulus (%), unary negation (-), and power (**). These can only work on integers and floating point values, with the exception of the addition operator which acts as concatenation for both strings and lists.

Boolean

The following operators return boolean values.

Equality (==) and Non-Equality (!=) work on all basic data types.

Greater Than (>), Greater than or equal to (>=), Less Than (<), and Less than or equal to (<=) only work when comparing any combination of integers to floating point values.

And (and), Or (or) and Logical Not (not) only work on boolean values.

Assignment

The assignment operator is simply the = character, and the right hand side will be evaluated and stored in the left hand side.

Definitions

The definition operator is simply the := character, and the right hand side will be stored in the left hand side, but not evaluated! This calculation will only be evaluated when needed. If the name found on the left hand side is found on the right hand side, then, if it exists, the current definition replaces the name on the left hand side.

Partial Evaluation

If the ! operator is found in an evaluation, it will be ignored. However, if found in a definition, then it will evaluate the name, or parenthesis group to the right and replace the old identifier in the definition.


Control Flow

For each, the structures create a new scope. Any variables defined inside the new scope will not be available one the scope is exited. However, old values can be redefined.

If/Else Statements

These are of the structure:

Where if the boolean value is true it evaluates the if body, and the else body otherwise.

There is also support for else if statements of the form:

Where the first match decides which statements body will be evaluated.

For any boolean value, it must be of a boolean type.

While Loops

These are of the form:

Where the inner body will be evaluated over several iterations as long as the boolean value evaluates to true.