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

Igor Stasenko siguctua at gmail.com
Sat Jul 25 10:08:24 UTC 2009


Oh, sorry, i just found that #valueWithPossibleArgs:  resembles the
same behavior, i.e. fills rest of arguments array with nils if there
is not enough.

So, the question mainly is that these two methods make each other
redundant, and one of them should be removed.

2009/7/25 Igor Stasenko <siguctua at gmail.com>:
> 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.
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list