[squeak-dev] #valueWithEnoughArguments: vs #valueWithPossibleArgs: ?

Igor Stasenko siguctua at gmail.com
Sat Jul 25 09:46:40 UTC 2009


I using the
#valueWithEnoughArguments:
in my project
but i found that BlockClosure doesn't implements that in 3.10 image i
updated from trunk.

There is, however
#valueWithPossibleArgs: anArray

But its a bit different , because it ensuring that block will be
evaluated even if you passing not enough arguments to it.
Strange design choice, btw:

valueWithPossibleArgs: anArray

	^numArgs = 0
		ifTrue: [self value]
		ifFalse:
			[self valueWithArguments:
				(numArgs = anArray size
					ifTrue: [anArray]
					ifFalse:
						[numArgs > anArray size
							ifTrue: [anArray, (Array new: numArgs - anArray size)]
							ifFalse: [anArray copyFrom: 1 to: numArgs]])]

Does it makes sense to pass 'anArray, (Array new: numArgs - anArray
size)'  at all, because
blocks usually using all arguments they expecting, and there is 99.9%
probability that passing nils to it will lead to errors.
But passing them in such style will make people wonder, where these
nils came from.


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list