Skip to content

Instantly share code, notes, and snippets.

@hashmal
Created April 19, 2013 19:07
Show Gist options
  • Save hashmal/5422477 to your computer and use it in GitHub Desktop.
Save hashmal/5422477 to your computer and use it in GitHub Desktop.
--------------------
-- SUDDENLY OOP!! --
--------------------
-- Let's simulate a class... But since it's Shirka, it has to be different.
-- Let's make an AGENT! It would just be a task spawner...
(agent => User) [ -- `agent` would wrap a list inside a `receive`, and
-- handle chores/boilerplate around it
initialize [ -- Constructor method
<< <<
"John" -- Tasks have their private stack, remember?
]
getName [ -- Simulate a method definition
>< << -> name
[ name ] | return
]
]
User [] new -- Spawn a new instance of the agent
[] :getName |<- -- Simulate a method invocation (just send a message)
puts -- Display the response
-- output: "John"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment