eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'MessageSend':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: MessageSend


Inheritance:

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

Package:
stx:libbasic
Category:
Kernel-Methods
Version:
rev: 1.28 date: 2018/05/04 10:07:02
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
usage example(s):
     (MessageSend receiver:nil selector:#foo) value

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
usage example(s):
     (MessageSend receiver:nil selector:#foo: argument:1) value

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
usage example(s):
     (MessageSend receiver:nil selector:#foo: arguments:#(1)) value


Instance protocol:

Compatibility-Squeak
o  cull: optionalFirstArg
activate the receiver with one or zero arguments.
Squeak compatibility, but also present in VW Smalltalk

o  cull: optionalFirstArg cull: optionalSecondArg
activate the receiver with two or less arguments.
Squeak compatibility, but also present in VW Smalltalk

o  cull: firstArg cull: optionalSecondArg cull: optionalThirdArg
activate the receiver with three or less arguments.
Squeak compatibility, but also present in VW Smalltalk

Compatibility-V'Age
o  evaluate

o  evaluateWith: someArgument

o  evaluateWithArguments: argArray

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  displayOn: aGCOrStream
Compatibility
append a printed desription on some stream (Dolphin, Squeak)
OR:
display the receiver in a graphicsContext at 0@0 (ST80).
This method allows for any object to be displayed in some view
(although the fallBack is to display its printString ...)

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.

testing
o  isBlockOrMessageSend


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 7.1.0.0; WebServer 1.663 at exept.de:8081; Wed, 19 Sep 2018 03:44:26 GMT