Skip to content

Commit

Permalink
Renamed Object#send_message:with_params: to Object#receive_message:wi…
Browse files Browse the repository at this point in the history
…th_params: as it makes more sense in terms of message passing semantics. The receiver is receiving a message and not supposed to send one to another object.
  • Loading branch information
bakkdoor committed Jun 23, 2011
1 parent 665ca8a commit 8fdace7
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/define_methods.fy
Expand Up @@ -4,12 +4,12 @@ arr define_singleton_method: "foo" with: {
self inspect println
}

arr send_message: 'foo
arr receive_message: 'foo

arr undefine_singleton_method: "foo"

try {
arr send_message: 'foo
arr receive_message: 'foo
} catch NoMethodError => e {
e println
}
2 changes: 1 addition & 1 deletion lib/enumerable.fy
Expand Up @@ -376,7 +376,7 @@ class FancyEnumerable {

if: (block is_a?: Symbol) then: {
sort() |a b| {
a send_message: block . <=> (b send_message: block)
a receive_message: block . <=> (b receive_message: block)
}
} else: {
sort(&block)
Expand Down
2 changes: 1 addition & 1 deletion lib/enumerator.fy
Expand Up @@ -104,7 +104,7 @@ class FancyEnumerator {

@fiber = Fiber new: {
param = |element| { yield: element }
@collection send_message: @iterator with_params: [param]
@collection receive_message: @iterator with_params: [param]
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/fancy_spec.fy
Expand Up @@ -317,7 +317,7 @@ class FancySpec {
and checks the return value.
"""

unless: (@actual_value send_message: msg with_params: params) do: {
unless: (@actual_value receive_message: msg with_params: params) do: {
SpecTest current failed: (@actual_value, params first)
}
}
Expand Down Expand Up @@ -369,7 +369,7 @@ class FancySpec {
and checks the return value.
"""

if: (@actual_value send_message: msg with_params: params) then: {
if: (@actual_value receive_message: msg with_params: params) then: {
SpecTest current failed_negative: @actual_value
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/object.fy
Expand Up @@ -446,9 +446,9 @@ class Object {
msg, params = msg
match type {
case 'async ->
self send_message: msg with_params: params
self receive_message: msg with_params: params
case 'future ->
val = self send_message: msg with_params: params
val = self receive_message: msg with_params: params
sender completed: val
}
} catch Exception => e {
Expand Down
6 changes: 3 additions & 3 deletions lib/proxy.fy
Expand Up @@ -23,8 +23,8 @@ class ProxyReceiver : BasicObject {
Forwards all incoming messages to @self to @@proxy and then @@obj.
"""

@proxy send_message: msg with_params: params
@obj send_message: msg with_params: params
@proxy receive_message: msg with_params: params
@obj receive_message: msg with_params: params
}
}

Expand Down Expand Up @@ -57,7 +57,7 @@ class RespondsToProxy : BasicObject {
"""

if: (@target responds_to?: msg) then: {
@target send_message: msg with_params: params
@target receive_message: msg with_params: params
}
}
}
4 changes: 2 additions & 2 deletions lib/rbx/object.fy
Expand Up @@ -94,7 +94,7 @@ class Object {
kind_of?(class)
}

def send_message: message {
def receive_message: message {
"""
@message Name of message to be sent to @self dynamically.
Expand All @@ -104,7 +104,7 @@ class Object {
send(message_name: message)
}

def send_message: message with_params: params {
def receive_message: message with_params: params {
"""
@message Name of message to be sent to @self dynamically.
@params @Array@ of parameters used with @message.
Expand Down
4 changes: 2 additions & 2 deletions lib/symbol.fy
Expand Up @@ -14,9 +14,9 @@ class Symbol {
"""

if: (arg is_a?: Array) then: {
arg first send_message: self with_params: $ arg rest
arg first receive_message: self with_params: $ arg rest
} else: {
arg send_message: self
arg receive_message: self
}
}
}
4 changes: 2 additions & 2 deletions tests/object.fy
@@ -1,12 +1,12 @@
FancySpec describe: Object with: {
it: "should dynamically evaluate a message-send with no arguments" when: {
obj = 42
obj send_message: 'to_s . is == "42"
obj receive_message: 'to_s . is == "42"
}

it: "should dynamically evaluate a message-send with a list of arguments" when: {
obj = "hello, world"
obj send_message: 'from:to: with_params: [0,4] . is == "hello"
obj receive_message: 'from:to: with_params: [0,4] . is == "hello"
}

it: "should dynamically define slotvalues" when: {
Expand Down

0 comments on commit 8fdace7

Please sign in to comment.