[squeak-dev] The Inbox: Environments-jr.70.mcz

Jakob Reschke jakob.reschke at student.hpi.de
Mon Feb 13 12:08:27 UTC 2017


Agreed. I based this on hasClassNamed: which uses the isKindOf: check as well.

classNamed: OTOH does not check the type and will also return a Trait.

2017-02-13 12:01 GMT+01:00 Bert Freudenberg <bert at freudenbergs.de>:
> On Sun, Feb 12, 2017 at 4:56 PM, <commits at source.squeak.org> wrote:
>>
>> A new version of Environments was added to project The Inbox:
>> http://source.squeak.org/inbox/Environments-jr.70.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Environments-jr.70
>> Author: jr
>> Time: 12 February 2017, 3:42:16.327498 pm
>> UUID: cbbca4a2-6a97-2b40-92b8-631bbfa519d0
>> Ancestors: Environments-jr.69
>>
>> add hasClassOrTraitNamed:
>>
>> useful for lists of behaviors
>>
>> =============== Diff against Environments-jr.69 ===============
>>
>> Item was added:
>> + ----- Method: Environment>>hasClassOrTraitNamed: (in category 'classes
>> and traits') -----
>> + hasClassOrTraitNamed: aString
>> +       Symbol hasInterned: aString ifTrue:
>> +               [:symbol | | value |
>> +               ^ ((value := declarations at: symbol ifAbsent: [nil])
>> +                       isKindOf: Class) or: [value isKindOf: Trait]].
>> +       ^ false.!
>
>
> Please do not introduce #isKindOf tests. All the other classOrTrait* methods
> use #isBehavior tests, which is way more general ... and also in line with
> your commit message ;)
>
> I'd rather implement this along the lines of "^(self classOrTraitNamed:
> aString) notNil" which would also make the argument compatible with the
> range of strings allowed by classOrTraitNamed:.
>
> We may want to add a Symbol internment check to that method, however.
>
> - Bert -


More information about the Squeak-dev mailing list