.
authorclaus
Fri, 12 May 1995 14:35:09 +0200
changeset 344 4b35f99afefb
parent 343 1cf554ea3773
child 345 cf2301210c47
.
MessageSend.st
--- a/MessageSend.st	Wed May 10 04:18:53 1995 +0200
+++ b/MessageSend.st	Fri May 12 14:35:09 1995 +0200
@@ -1,6 +1,6 @@
 "
  COPYRIGHT (c) 1994 by Claus Gittinger
-              All Rights Reserved
+	      All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -11,17 +11,17 @@
 "
 
 Message subclass:#MessageSend
-         instanceVariableNames:'receiver'
-         classVariableNames:''
-         poolDictionaries:''
-         category:'Kernel-Methods'
+	 instanceVariableNames:'receiver'
+	 classVariableNames:''
+	 poolDictionaries:''
+	 category:'Kernel-Methods'
 !
 
 MessageSend comment:'
 COPYRIGHT (c) 1994 by Claus Gittinger
-              All Rights Reserved
+	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libbasic/MessageSend.st,v 1.2 1994-10-10 00:53:52 claus Exp $
+$Header: /cvs/stx/stx/libbasic/MessageSend.st,v 1.3 1995-05-12 12:35:09 claus Exp $
 '!
 
 !MessageSend class methodsFor:'documentation'!
@@ -29,7 +29,7 @@
 copyright
 "
  COPYRIGHT (c) 1994 by Claus Gittinger
-              All Rights Reserved
+	      All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -42,7 +42,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libbasic/MessageSend.st,v 1.2 1994-10-10 00:53:52 claus Exp $
+$Header: /cvs/stx/stx/libbasic/MessageSend.st,v 1.3 1995-05-12 12:35:09 claus Exp $
 "
 !
 
@@ -54,12 +54,17 @@
     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 use.
+    but blocks are somewhat more expensive in their creation and require
+    more storage.
+
     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. 
     Thus it is not sure, which one is faster in the end ...
 
+    If you plan to write a simulator and want to queue cillions of blocks,
+    try to use MessageSends (or even: message); this will save you a lot memory.
+
     Example:
 
        |m|
@@ -67,17 +72,37 @@
        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:something selector:#foo arguments:#().
+	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
+	...
 "
 ! !
 
@@ -86,7 +111,7 @@
 receiver:r selector:sel arguments:argArray
     |newMessage|
 
-    newMessage := super setSelector:sel arguments:argArray.
+    newMessage := super new setSelector:sel arguments:argArray.
     newMessage receiver:r.
     ^ newMessage
 ! !