Plastic is a pluggable, flexible, extensible MOOcode parser/compiler. Plastic currently implements all of LambdaMOO's existing language features, with a few slight deviations from and/or extensions to the original syntax.
The Plastic parser is not a full fidelity reimplementation of the LambdaMOO language syntax. Users should note the changes below.
Semicolons are allowed everywhere they can be used with standard MOOcode syntax, but they are optional in many common cases. The following are functionally identical:
x = 5;
x = 5
The parser uses special same-line rules to enforce expected behavior in a couple common cases.
return
keyword.The from/use
import syntax introduces a shorthand syntax for verb invocation and property access. It allows the programmer to predeclare the target of an identifier that will be used for verb invocation or property access, and then to use the identifier without the target.
In code that makes frequent use of verbs and properties on $core.utility.time
, the following syntax allows the common target to be omitted.
from $core.utility.time use format
from $core.utility.time use months, days
format("$Y") // equivalent to $core.utility.time:format("$Y")
months[$] // equivalent to $core.utility.time.months[$]
The target specified after the keyword from
can also be the keyword this
or the name of an object in a package as used by $lookup()
.
from this use log
from "composed|kernel" use reinitialize
I changed scattering assignment slightly. In particular, the leading ?
is no longer required/allowed in front of parameters with defaults.
Use {a, b = 1, c = 2}
instead of {a, ?b = 1, ?c = 2}
.
Yes, I know this change removed support for optional but unassigned parameters.
Error catching syntax for expressions is simplified. The error catching operator is now the ternary operator !!
, and the leading backtick (`
) and ending single-quote ('
) are no longer required.
Use foo !! bar => baz
instead of `foo ! bar => baz'
.
Strings can be enclosed in either single ('
) or double ("
) quotes. This alleviates some of the quoting misery I run into and is reasonably prominent in other languages.
The exponentiation operator is **
instead of ^
. I am using ^
as a positional operator in a similar fashion to $
to indicate the first element of a list or map in indexed/ranged access.
end
can be used in place of endfor
, endif
, and kin. The original endings are supported, as well.