Language
Method Calls
Ghost is deeply object oriented, so most code consists of invoking methods on objects, usually something like this:
dog.speak("Throw the ball!")
You have a receiver expression (here dog
) followed by a .
, then a name (speak
) and an argument list in parentheses (("Throw the ball!")
). Multiple arguments are separated by commas:
dog.command("fetch", "ball")
The argument list can also be empty:
dog.sit()
Ghost executes a method call like so:
- Evaluate the receiver and arguments from left to right.
- Look up the method on the receiver's object.
- Invoke it, passing in the argument values.