Hi:

I am trying to understand the different between and perhaps origin of 
BlockClosure>>#valueWithPossibleArgs: and 
BlockClosure>>#valueWithEnoughArguments:

I am trying to decide which of the two I need for SOMns.

The first one has seen more recent changes, when looking at the Pharo 6.1 
download:

valueWithPossibleArgs: anArray    —>  2/12/2017 StephaneDucasse
valueWithEnoughArguments: anArray —>  3/11/2001 nk

While they have rather different implementations, they seem to behave 
identically, as far as I could tell using the following example:

blocks := {
  [ { } ].
  [:a | { a } ].
  [:a :b | { a. b } ].
  [:a :b :c | { a. b. c } ]
}.

blocks collect: [:b | b valueWithPossibleArgs: {1}].
blocks collect: [:b | b valueWithPossibleArgs: {1. 2. 3}].
blocks collect: [:b | b valueWithEnoughArguments: {1}].
blocks collect: [:b | b valueWithEnoughArguments: {1. 2. 3}].

I was also wondering how they relate to #cull:*

One of the major differences seems to be that valueWithP* and valueWithE* are 
both injecting nil for absent arguments, while normal #value* and #cull* 
methods signal an error.
Is there a specific use case why one wouldn’t want to be strict here as well, 
but instead inject nils?

Any comments or pointer appreciated.

Thanks
Stefan


-- 
Stefan Marr
School of Computing, University of Kent
http://stefan-marr.de/research/



Reply via email to