Public Domain 2023 Douglas Crockford
The Misty Programming Language is a dynamic, general-purpose, transitional, actor language. It has a gentle syntax that is intended to benefit students, as well as advanced features such as capability security and lambdas with lexical scoping.
The grammar of the language is expressed in McKeeman Form.
The language is quite strict in its use of spaces and indentation. In most programming languages, code spacing and formatting are under specified, which leads to many incompatible conventions of style, some promoting bug formation, and all promoting time-wasting arguments, incompatibilities, and hurt feelings. Misty instead allows only one convention which is strictly enforced. This liberates programmers to focus their attention on more important matters.
space
' '
Indentation is in increments of 4 spaces. The increment increases when the last token
on a line is '('
, '{'
, or '['
, and decreases just
before the matching ')'
, '}'
, ']'
.
The indent rule adds four spaces to the indentation and ends the line. The outdent rule removes four spaces from the indentation and ends the line.
indent increase_indentation linebreak
outdent decrease_indentation linebreak
The linebreak rule allows the insertion of a comment, ends the line, and checks the indentation of the next line. Multiple comments and blank lines may appear wherever a line can end.
linebreak comments linefeed indentation
linefeed
'000A'
There are many places were the language expects an end of line, such as at the end of a statement.
Misty is strict about whitespace in order to eliminate the need for, debate over, and circumvention of coding standards. Misty starts with the pretty convention of JSON formatting. For example, JSON allows this compact JSON text
{"one":1,"array":[1,2,3],"text":"hello"}
to be presented more pleasingly as
{ "one": 1, "array": [ 1, 2, 3 ], "text": "hello" }
Misty takes this further by eliminating the comma at the end of a line, and eliminating quotes on field names in most cases.
{ one: 1 array: [ 1 2 3 ] text: "hello" }
Misty uses the same convention with (
left paren and )
right paren in argument lists and expressions. In an open argument list, each argument goes on its own line and the commas between the arguments are eliminated.
my_button.on( "click" ƒ (event) { call event.done() call take_action() } )
In complex expressions, parens can allow a line break.
def atan: ƒ (slope) ( sin( slope / (sqrt(slope * slope) + 1) ) ) let progress: (
result + (radicand / result)
) / 2
A comment begins with an #
octothrope and ends with the end of the line.
Comments are used to provide context and motivation to help humans understand the programming.
The Misty System strictly ignores all comments.
comments
""
comment more_comments
comment
spaces '#'
cchars
more_comments
""
linefeed comment more_comments
spaces
""
space spaces
cchars
""
cchar cchars
cchar
'0020'
. '10FFFF'
Names are used to identify fields, variables, modules, actors, and parameters.
Names are made of letters.
A name must be longer than one letter.
Names may contain _
underbar to improve intelligibility.
CamelCase is not allowed.
Names may end with ?
question mark which is used to indicate predicates and truth values.
name
upper upper name_upper
upper lower name_lower
upper '_'
name_part
lower lower name_lower
lower '_'
name_part
name_part upper name_upper lower name_lower
name_upper upper name_upper name_lower
name_lower
""
'?'
'_'
name_part
lower name_lower
upper
'A'
. 'Z'
lower
'a'
. 'z'