PreviousUpNext

10.4.2  Non-alphabetic identifiers

Even though technically Mythryl does not determine whether an identifier is infix or not based on its syntax, in practice Mythryl like most languages uses non-alphabetic identifiers primarily as infix operators. Some of the default bindings include:

    +                    # Addition,    both integer and floating point.
    -                    # Subtraction, both integer and floating point.
    /                    # Division,    both integer and floating point.
    %                    # Modulus,     both integer and floating point.
    |                    # Bitwise 'or',  integer.
    &                    # Bitwise 'and', integer.
    ^                    # Bitwise 'xor', integer.

Unlike languages such as C, these are simply default bindings which may be readily overridden by the application programmer. (For one example of doing so to good effect see the Parsing Combinators I tutorial.)

Mythryl non-alphabetic identifiers have the syntax

    [\\!%&$+/:<=>?@~|*^-]+

which is to say basically any string of ascii special characters other than

    ( ) { } ; , . " ' ` _ #

Some non-alphabetic identifiers are reserved and not available for programmer use as vanilla identifiers:

    .     # Used in  record.field           syntax.
    :     # Used in  var: Type              syntax.
    ::    # Used in  package::element       syntax.
    !     # Used in  head ! tail            syntax.
    =     # Used in  pattern = expression   syntax.
    ==    # Used in  expr == expr           syntax.
    =>    # Used in  pattern => expression  syntax.
    ->    # Used in  Type -> Type           syntax.
    ??    # Used in  boolexp ?? exp :: exp  syntax.

    &=    # i &= j   is shorthand for   i = i & j.
    @=    # i @= j   is shorthand for   i = i @ j.
    \=    # i \= j   is shorthand for   i = i \ j.
    $=    # i $= j   is shorthand for   i = i $ j.
    ^=    # i ^= j   is shorthand for   i = i ^ j.
    -=    # i -= j   is shorthand for   i = i - j.
    .=    # i .= j   is shorthand for   i = i . j.
    %=    # i %= j   is shorthand for   i = i % j.
    +=    # i += j   is shorthand for   i = i + j.
    ?=    # i ?= j   is shorthand for   i = i ? j.
    /=    # i /= j   is shorthand for   i = i / j.
    *=    # i *= j   is shorthand for   i = i * j.
    ~=    # i ~= j   is shorthand for   i = i ~ j.
    ++=   # i ++= j  is shorthand for   i = i ++ j.
    --=   # i --= j  is shorthand for   i = i -- j.

Comments and suggestions to: bugs@mythryl.org

PreviousUpNext