UpNext

10.5.1  Whitespace sensitivity

Mythryl is more sensitive to the presence or absence of whitespace than most contemporary languages. In particular, Mythryl uses the presence or absence of whitespace around an operator to distinguish between prefix, infix, postfix and circumfix applications:

    f - g                # '-' is binary -- subtraction.
    f  -g                # '-' unary prefix -- negation:  f(-g).

    f | g | h            # '|' is infix: "f or g or h".
    f  |g|  h            # '|' is circumfix -- absolute value: "f(abs(g)(h)".

    f * g                # '-' is binary -- multiplication.
    f  *g                # '-' is unary -- dereference:  f(*g).

    f g ! h              # '!' is binary -- list construction: (f(g)) ! h
    f g!  h              # '!' is unary postfix -- factorial:  f(g!)(h).

The amount or kind of whitespace does not matter; only whether it is present or not.

Mythryl treats prefix, postfix and infix forms of a given operator as completely separate identifiers. Thus, you may bind the infix form of * to a new function without affecting its prefix interpretation.


Comments and suggestions to: bugs@mythryl.org

UpNext