Hi Matthieu,
Le 27 févr. 2012 à 01:57, Mathieu SUEN a écrit :
> Hi All
>
> I have added +map support to NSDictionary with the following method:
> - (NSArray*) mapValues: (id)aClosure;
> - (NSArray*) mapKeys: (id)aClosure;
> - (void) foreachKeysAndValues: (id)aClosure;
> - (void) foreachKeys: (id)aClosure;
> - (void) foreachValues: (id)aClosure;
Instead of adding new API like -mapValues:, -mapKeys: etc. etc why not do as
below?
dictionary values map: [ ]
I would have the same reasoning for the last foreach methods.
> If people founded valuable I can commit them. The wording in ST-80 would have
> been -collect: and -do: (-keysAndValuesDo: ..) but I have stick to the rules
> founded in NSArray+map.h
All Foundation collections support the HOM and block methods declared in
ETCollection+HOM.h (see EtoileFoundation/Headers).
I tend to use this API when I write Smalltalk code, rather than NSArray+map
which is something much older and hasn't been updated for a while.
I could be wrong, but I thought that NSArray+map was present to support a
Smalltalk-80 API, in addition to the EtoileFoundation collection block API.
So I would say it's probably better to use the ST-80 wording rather than to
introduce a new one, given that we already have our own with
ETCollection+HOM.h.
What would be nice is to change NSArray+map to be something more generic like
ETCollection+Smalltalk, that would add the common ST-80 collection methods to
the various Foundation collections, and leverage ETCollection+HOM as much as
possible.
Cheers,
Quentin.
_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss