Skip to content

Instantly share code, notes, and snippets.

@justinmchase
Last active August 29, 2015 14:11
Show Gist options
  • Save justinmchase/edc1bd6dced22d6349bb to your computer and use it in GitHub Desktop.
Save justinmchase/edc1bd6dced22d6349bb to your computer and use it in GitHub Desktop.
A hypothetical compositional language
component c1 {
function receive(message: string) { // handles "receive" messages
print(message)
}
}
component c2 {
var running: bool
function run() { // Handles the "run" message
if(!running)
running = true
this->receive("hello world!") // Sends a message to "receive" with an argument
else
this->receive("error!")
}
}
// An object containing the above components
var x = {
c1 = new c1()
c2 = new c2()
}
// send a message to components on x named "run"
x->run() // > hello world!
x->run() // > error!
var x = { } // an empty object
var y = {
value: "hi" // any value type, not a function
}
var z = Root { // a named object
}
var j = Root { // An object with children
First {
}
Second {
}
}
for(var child in j) {
print(child.name) // First, Second
}
j.First.foo() // Get child named "First" send it a message named "foo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment