Objects in this language are defined as type
s. They have properties with
default values that can be overridden in the constructor literal syntax.
There are no methods, but instead have conditional message handlers. The handlers are scoped by the state of the internal properties. Depending on the state the value is in, different messages can be responded to in different ways.
Also values can actively delete themselves causing all references to them to be deleted and replaces with a null type that doesn't respond to anything. (thus freeing up memory)
type Ball:
life = 100
x = 0
y = 0
when life > 0:
on draw(canvas):
canvas.circle(x, y, 10, :red)
on update(ms):
life -= 1
x += ms
else:
delete
type Canvas:
on circle(x,y,r,c):
...
canvas = <Canvas>
ball = <Ball x=64 y=64>
ball.update(10)
ball.draw(canvas)
This could fit perfectly into my ccJSON parser. I have been looking for micro languages to embed that can deal with object property manipulation in response to messages.
What would be the easiest way to compile a syntax such as this to pure JS?