#do: is currently the only method which any subclass of Collection is required to implement in order to inherit all of the other behaviors. #at:, et al, are "direct access" methods which are not required for Collections and, in cases like Set, not even *supported*, so we would probably need to duplicate various #shouldNotImplement's overrides in Set and possibly other subclasses. That would leave the superclass saying, "subclassResponsibility" and the subclasses saying, "shouldNotImplement", which feels conflicted. I think is one of those cases where a little duplication of the #at: method(s) is worth it so we don't have to explicitly delete the behavior.
On Thu, Apr 12, 2018 at 12:15 PM, Eliot Miranda eliot.miranda@gmail.com wrote:
Hi Chris,
On Fri, Mar 30, 2018 at 3:57 PM, commits@source.squeak.org wrote:
Chris Muller uploaded a new version of Collections to project The Trunk: http://source.squeak.org/trunk/Collections-cmm.785.mcz
==================== Summary ====================
Name: Collections-cmm.785 Author: cmm Time: 30 March 2018, 5:57:37.727038 pm UUID: 37e9870a-5379-4185-8538-fada710dad5d Ancestors: Collections-eem.784
Add #at:ifPresent:ifAbsent: for API compatibility with other kinds of directly-accessible Collections.
=============== Diff against Collections-eem.784 ===============
Item was added:
- ----- Method: SequenceableCollection>>at:ifPresent:ifAbsent: (in
category 'accessing') -----
- at: index ifPresent: elementBlock ifAbsent: exceptionBlock
"Answer the value of elementBlock on the element at position
index. If I do not contain an element at index, answer the result of evaluating exceptionBlock."
^ elementBlock value:
(self
at: index
ifAbsent: [ ^ exceptionBlock value ])!
I'm thinking that this sits better in Collection as a default implementation. I note that also we don't have a subclass responsibility implementations of at:ifAbsent: (and maybe others) in Collection. _,,,^..^,,,_ best, Eliot