px
px copied to clipboard
PX language - parser and runtime
Goals:
-
Uniformity:
- Everything is an object
- The program itself is an object (homoiconity)
- All objects are expressions (thus everything is an expression)
- Value objects are expressions that return themselves
- Expression objects are expressions which evaluate to something other than themselves
- All objects are dictionaries (thus everything is a dictionary)
- Dictionary keys are objects (not strings)
- All objects are mailboxes (thus everything is an actor)
- Objects can receive messages
- Programs can send messages to objects
- Everything is an object
-
Minimalism:
- Minimal syntax, enough syntax to be expressive
- No keywords
- Infix, not prefix (lisp) or postfix (forth)
- All infix expressions are evaluatable objects
- Tree-structure inherit in syntax
- Minimal builtin data types
- so far: string, integer, float, object (table)
- Minimal syntax, enough syntax to be expressive
-
Ease:
- Readability - infix in spite of added parsing complexity
- But the infix notation is just syntactic sugar, not an additional language element
- Should be simple to expose a C function or C++ class to the VM
- Readability - infix in spite of added parsing complexity
Basic syntax:
- all operators all just messages delivered to the receiving object
- valid operators:
- any valid infix operator
- pairing operators: ':', ',', ';', '\n'
- misc operators: [], []=,
- code block operator: { }
- operations on local variables send messages to the current context
- identifier
- identifier = value
- message syntax:
- obj msg
- obj msg { block }
Open questions:
- What kinds of messages are there? So far:
- Function call - context push
- Fiber - context switch
- Why separate mechanisms for attributes (table) and messages?
- Nonuniformities:
- How can we turn lvar/lasgn into messages?
- How can we turn { } into a message?
- Once all expression nodes have been reduced to messages, where do we go from there?