'From Cuis 2.6 of 10 August 2010 [latest update: #540] on 22 August 2010 at 10:03:34 pm'!

!WeakMessageSend commentStamp: 'jmv 8/22/2010 21:48' prior: 0!
Instances of WeakMessageSend encapsulate message sends to objects, like MessageSend. Unlike MessageSend it is not necessarily a valid mesage.  A request to value only results in a send if in fact it is valid. 

See MessageSendComments also. WeakMessageSend is used primarily for event regristration. 

Unlike MessageSend WeakMessageSend stoes receiver (object receiving the message send) as a the first and only element of its array as opposed to a named ivar.
But like MessageSend, it does have
 selector		Symbol -- message selector
 arguments		Array -- bound arguments
and it also has
 shouldBeNil		Boolean --  used to ensure array of arguments is not all nils!


!WeakActionSequenceTrappingErrors methodsFor: 'evaluating' stamp: 'jmv 8/22/2010 22:01'!
valueStartingFrom: startIndex
	"Do the same as my parent, but make sure that all actions that do not 
	give errors are evaluated before resignaling the ones that gave errors 
	(giving the chance to clients to handle them)."

	"Note: I currently trap Halt, Error so that I am sure to get a Halt event in case of a Halt. This is being fixed in the exception system - when the fix is done it will be enough to capture only Error."

	| each answer |
	startIndex to: self size do: [:index |
		each := self at: index.
		[ answer := each value ]
			on: Halt, Error
			do: [:exc | 
				self valueStartingFrom: index + 1.
				exc pass]].
	^ answer! !

!WeakActionSequenceTrappingErrors methodsFor: 'evaluating' stamp: 'jmv 8/22/2010 22:03'!
valueWithArguments: anArray startingFrom: startIndex
	"Do the same as my parent, but make sure that all actions that do not 
	give errors are evaluated before resignaling the ones that gave errors 
	(giving the chance to clients to handle them)."

	"Note: I currently trap Halt, Error so that I am sure to get a Halt event in case of a Halt. This is being fixed in the exception system - when the fix is done it will be enough to capture only Error."

	| each answer |
	startIndex to: self size do: [:index |
		each := self at: index.
		[ answer := each valueWithArguments: anArray ]
			on: Halt, Error
			do: [:exc | 
				self valueWithArguments: anArray startingFrom: index + 1.
				exc pass]].
	^ answer! !


!WeakMessageSend methodsFor: 'private' stamp: 'jmv 8/22/2010 21:54'!
withEnsuredReceiverDo: aBlock
	"Grab a real reference to receive. If still there, evaluate aBlock."
	"Return nil if my receiver has gone away"

	^ self receiver ifNotNil: [ :r | aBlock value: r ]! !

