Methods

From Reia

Jump to: navigation, search

Arrow methods

Reia supports an asynchronous approach to method dispatch in the form of "arrow methods". You may be familiar with invoking methods on objects using the object->method syntax. The arrow generally implies at least one of the following: the call is being made to something remote, and the call is being made in the form of a message. Reia flips the arrow around, to make it clear you're sending a message to the object. When invoking an arrow method in Reia, it takes the form object<-method.

Arrow methods send messages to objects. However, unlike methods in other object oriented languages, arrow methods don't wait for a response. The message is enqueued for later processing by its receiver, and you're free to go about your business.

Example:

foo = Foo.new
foo<-bar("baz!")

In the class definition for the receiver, special syntax is used to designate that a given method is an arrow method:

class Foo
  def ->bar(arg)
    puts(arg)

The "->" token designates that a given method is an arrow method.

Personal tools