Plof's design
Plof is intended to be an extremely flexible programming language. This is reflected in the language in many ways:
- The grammar of the language is not defined by the Plof implementation, but by the standard library and in Plof code. The grammar may be changed or extended at any time.
- Plof uses a prototype-based object system. Unlike some other prototype-based systems (but like the original prototype-based system, Self), Plof allows multiple inheritance. It does this by using an array lookup for prototypes instead of a linked list: Every object has an array of all its prototypes, which may potentially come from two "paths".
- Objects are generally defined by object literals, the syntax of which is intended to echo classes, making life easier for programmers used to class-based systems. For example, a List type may look like
var List = Object : [
this(next, val) {
this.next = next
this.val = val
}
map = (fun) {
if (next) (
new List(next.map(fun), fun(val))
) else (
new List(Null, fun(val))
)
)
]- Expressions are lazily evaluated. As it turns out, this doesn't hurt imperative programming substantially, since statements are still evaluated in order, and the order of evaluation of expressions within a statement is undefined in most programming languages (in fact, it's more rigorously defined in Plof than many other languages)
- Everything is an object. Everything.
- Currying is fundamental to the language. This, in concert with lazy evaluation, allows the if statement and other traditionally-inbuilt constructs to be implemented instead as functions. The if function, for example, looks like this:
var if = (cond) {
((cond&&True).
ifTrue( return ((then) { then; selff }); )).
ifFalse(return ((then) { id }); )
}, and is called like this:
if (condition) (
// code to run if the condition is true
) else (
// code to run if the condition is false
). Note the use of parenthesis instead of braces: These aren't blocks, they're just expressions which may or may not be evaluated by "if".
- The syntax is intended to be relatively light. Plof is still, however, a brace-language, so its syntax is heavier than many functional languages in particular. Function calls are simply a list of expressions (as in many functional languages), object literals have the same syntax as statements, etc. To what degree this goal was actually successful is arguable, however :)