Move logo

Move is a modern and simple programming language which can run on virtually any computer. Move is primarily aimed towards people not previously familiar with programming computers.

logo.png logo.pdf (for high-resolution work)
Disable this fancy context menu

Language reference

This is a summary of the Move language and not a complete reference. Please see the ECMA-262 specification for details.


Value types

There are five different value types in Move: numbers, text, lists, objects and functions.

Numbers

Numbers can be written in either decimal, hexadecimal or octal notation.

The Number type has exactly 18437736874454810627 (that is, 264-253+3) values, representing the double- precision 64-bit format IEEE 754 values as specified in the IEEE Standard for Binary Floating-Point Arithmetic, except that the 9007199254740990 (that is, 253-2) distinct “Not-a-Number” values of the IEEE Standard are represented in ECMAScript as a single special NaN value.

Example: 1234 1234 1234 true

print 1234
print 0x4d2
print 02322
print 1234 == 1234.0

Text

Text can contain any Unicode characters and is stored as UTF-16 text. A piece of text is denoted by enclosing quotation marks (“ and ” or ‘ and ’) with any text except line breaks or (same as the enclosing) quotation marks. Standard escape sequences (like “\n” and “\t”) as well as Unicode escape sequences (“\u” followed by four hexadecimal digits) can be used to encode any Unicode character into the text, like line breaks. The backslash character (“\”) can also be used to escape characters like an embedded quotation mark.

Text is internally represented by Text objects (an alias for String JavaScript objects). Adding functions to the Text object’s prototype will make that function available to any text value.

Example of calling the built-in split function on a piece of text to produce a list of substrings: [“Kittens”, “are”, “cute”]

print "Kittens are cute".split(" ")

Lists & arrays

A List (or Array) is a form of compound value which contains other values in a ordered sequence. Lists are composed by enclosing zero or more values in a square bracket character pair (“[” and “]”), separated by comma characters. Lists can also be created by programmatic composition. The built-in Array object’s prototype is the prototype used for new lists.

Example of programmatic composition: [“Kittens”, “are”, “cute”]

list = []
list.push "Kittens"
list[1] = "are"
list[list.length] = "cute"
print list

Objects

The Object type is fundamental to Move (and JavaScript) as all other values are in fact Objects. E.g. a Number is a special type of Object. We say that “Move contains five different types of values” which is a simplification. Move has in fact only one type — Object — but at the same time, the language and the runtime treats some Object subtypes differently, like Numbers which can be used for mathematical operations or text which when “added” together creates a new piece of text being the two texts glued together. Therefore we simplify value types by saying there’s only five of them.

An Object is a set of (unique) keys with associated values. Keys must be text values, but an associated value can be of any type. Objects are denoted by a pair of curly brackets (“{” and “}”) holding zero or more key-value pairs. Keys are written either as regular text with wrapping quotation marks or without wrapping quotation marks for text which conforms to the rule that it is a valid name (starts with a-z, A-Z, _ or $ and is followed by zero or more letters, numbers, etc). A key is terminated by a colon character and is followed by a value expression. Two successive key-value pairs are separated by a comma character.

Example: 1 2 undefined 3

obj = {a:1, "b-B":2}
print obj.a
print obj["b-B"]
print obj.c
obj.c = 3
print obj.c

Functions

Functions are denoted by a circumflex accent character (““) optionally followed by argument declarations wrapped in a parenthesis character pair (”(“ and ”)“), finally followed by a block of code wrapped in a pair of curly bracket characters (”{“ and ”}“).

The block of code in a function has it’s own scope — a variable defined (assigned for the first time) in such a block will “live” in that block, thus any references to that variable before the declaration of the code block will refer to another, probably undefined, variable.

The last statement in a function’s code block is returned. There’s also a special “return” keyword which can be used to prematurely return a value from a function.

Arguments can have explicit default values which are denoted by a postfix assignment operator (“=”) for the argument name followed by a value. If no explicit default value is given, the “undefined” atom is used.

Here is an illustrating example of how scope works. The following code will yield a reference error with the message “x is not defined” since “x” is defined in the “y” function’s scope and is thus not available to the outer scope: ReferenceError: x is not defined …

y = ^{ x = 5 }
y{}
print x

Here we assign something to x in the outer scope which will tell Move that “x” should live and be available in that (outer) scope: 5

x = 0
y = ^{ x = 5 }
y{}
print x

Atoms

Move has a set of “atoms” which are basically pre-defined constants with itself as its value. They are called “atoms” since there is only one single, global and immutable instance (or “version” if you will) of each of these special values:

Example: true true true

print true != false
print undefined != null
Yes = true
print Yes == true

List slices

Move features a syntax for extracting and assigning slices of collections.

This special slice syntax compiles down to two different method calls depending on whether a slice is read or written:

Slice syntax was introduced in Move 0.2.0

Example: el hel     [ 2, 3 ] [ 3, 4 ]   [ 1, 2, 3, 4 ]   [ 1, 9, 4 ]

print "hello"[1:3]
print "hello"[:-2]

x = [1,2,3,4]
print x[1:3]
print x[-2:]

print x
x[1:3] = [9]
print x

Embedded HTML

Embedded HTML — or “EHTML” — is a way to embed HTML inside Move code: …<div class=“profile-picture”>↩ <img src=“profile-pictures/↩ rsms.jpg” alt=“”></div>…

img = ^(src, alt) { <img src="{src}" alt="{alt}" />  }

profilePicture = ^(username) {
  div = <div class="profile-picture" />
  div.appendChild img 'profile-pictures/'+username+'.jpg'
  div
}

document.body.appendChild profilePicture 'rsms'

EHTML is enabled by default when running in a web browser. It’s otherwise disabled by default. EHTML is a preprocessor and can be explicitly enabled or disabled using the “enable” and “disable” pragma directives.

The following will cause errors during compilation in Node.js:

foo = <div/>

But if we tell the compiler to preprocess EHTML even though we are not in a web browser, the code will compile just fine in Node.js:

#pragma enable ehtml
foo = <div/>

Same thing goes for the “disable” pragma. The following code will cause compilation errors in any environment:

#pragma disable ehtml
foo = <div/>

Embedded HTML was introduced in Move 0.3.0