eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MessageSend':

Home

everywhere
www.exept.de
for:
[back]

Class: MessageSend


Inheritance:

   Object
   |
   +--Message
      |
      +--MessageSend
         |
         +--Event

Package:
stx:libbasic
Category:
Kernel-Methods
Version:
rev: 1.21 date: 2008/12/17 16:23:19
user: cg
file: MessageSend.st directory: libbasic
module: stx stc-classLibrary: libbasic
Author:
Claus Gittinger

Description:


Instances of MessageSend can be used for simulation programs.
They keep some receiver, selector and arguments and can be evaluated
at any time later. (basically, they are like MessageObjects, but keep
the receiver in addition to the selector & arguments).

They can also be used as replacement for simple [self foo]-blocks.
Of course, they could also be replaced by blocks such as
'[receiver perform:selector withArguments:arguments]', 
but blocks are somewhat more expensive in their creation and require
more storage.

If you plan to write a simulator and want to queue cillions of blocks,
try to use MessageSends instead of blocks
(or even: message, if the receiver is constant);
this will save you a lot of memory.

However, the send-operation itself is faster in a block, since it
will use a better caching scheme (inline-cache) for its send, while
sending here is done with a #perform:, which is not inline-cached. 
Also, blocks are more flexible, in that they allow access to local
variables of the defining method - and work without a need to define an
extra visited method (read literature on visitor patterns).

Thus it is not sure, which one is actually better to use ...

You can either store arguments in the messageSend object, or
leave them undefined until the send is actually performed, and
pass any arguments with the value:-messages.


Related information:

    Block
    Message

Class protocol:

instance creation
o  receiver: r selector: sel
create & return a new instance which can be used to
send sel to some receiver, r

o  receiver: r selector: sel argument: something
create & return a new instance which can be used to
send sel with arguments to some receiver, r

o  receiver: r selector: sel arguments: argArray
create & return a new instance which can be used to
send sel with arguments to some receiver, r


Instance protocol:

accessing
o  argumentCount
VisualAge/ANSI compatibility: return the number of arguments of the message

o  numArgs
return the number of arguments of the message

o  receiver
return the receiver of the message

o  receiver: r
set the receiver of the message

evaluation
o  value
evaluate the messagesend with the original arguments

o  value: someArgument
evaluate the messagesend, with someArgument instead of the original

o  value: arg1 value: arg2
evaluate the messagesend, with arg1 and arg2 instead of the original
arguments

o  value: arg1 value: arg2 value: arg3
evaluate the messagesend, with arg1, arg2 and arg3 instead of the original
arguments

o  valueWithArguments: argArray
evaluate the messagesend, with arguments taken from argArray,
instead of the original arguments

o  valueWithOptionalArgument: arg
evaluate the messagesend.
Optionally pass an argument (if the selector is for a one arg message).

o  valueWithOptionalArgument: arg1 and: arg2
evaluate the messagesend.
Optionally pass up to two arguments.

printing & storing
o  displayString
return a string for display in inspectors etc.

o  printOn: aStream
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.


Examples:


Example: |m| m := MessageSend receiver:1 selector:#+ arguments:#(2). m value. is almost the same as: |m| m := [1+2]. m value. Example2 (a simulation) |q| q := Queue new. ... 'put some action into the queue' q nextPut:(MessageSend receiver:someone selector:#foo arguments:#(). ... 'evaluate next action from the queue' q next value ... if all sends are going to the same receiver, use: |q| q := Queue new. ... 'put some action into the queue' q nextPut:(Message selector:#foo arguments:#(). ... 'evaluate next action from the queue' q next sendTo:someone ...

ST/X 6.1.1; WebServer 1.620 at exept:8081; Wed, 23 May 2012 20:02:46 GMT