[squeak-dev] The Inbox: Kernel-kfr.1339.mcz

karl ramberg karlramberg at gmail.com
Wed Sep 16 16:57:11 UTC 2020


 This works:
Class>>binding
"Answer a binding for the receiver, sharing if possible"
(Smalltalk globals bindingOf: name ifAbsent: nil) ifNotNil:
[:bindingOrNil|
bindingOrNil value == self ifTrue:
[^bindingOrNil]].
^ClassBinding key: nil value: self

On Wed, Sep 16, 2020 at 6:54 PM karl ramberg <karlramberg at gmail.com> wrote:

> I tested this change.
> I get a DNU for 'bindingOf: ifAbsent:' because 'self environment'
> evaluates to Smalltalk here.
>
> Best,
> Karl
>
>
>
> On Wed, Sep 16, 2020 at 12:01 AM Eliot Miranda <eliot.miranda at gmail.com>
> wrote:
>
>> Hi Karl,
>>
>> On Mon, Sep 14, 2020 at 10:48 PM <commits at source.squeak.org> wrote:
>>
>>> A new version of Kernel was added to project The Inbox:
>>> http://source.squeak.org/inbox/Kernel-kfr.1339.mcz
>>>
>>> ==================== Summary ====================
>>>
>>> Name: Kernel-kfr.1339
>>> Author: kfr
>>> Time: 15 September 2020, 7:48:44.907977 am
>>> UUID: 9e1761d0-c2a1-b74a-bfe7-90dd49e320f1
>>> Ancestors: Kernel-ct.1338
>>>
>>> Fix a deprecation warning
>>>
>>> =============== Diff against Kernel-ct.1338 ===============
>>>
>>> Item was changed:
>>>   ----- Method: Class>>binding (in category 'compiling') -----
>>>   binding
>>>         "Answer a binding for the receiver, sharing if possible"
>>>         | binding |
>>> +       binding := Smalltalk globals associationAt: name ifAbsent: [nil
>>> -> self].
>>> -       binding := self environment associationAt: name ifAbsent: [nil
>>> -> self].
>>>         ^binding value == self ifTrue:[binding] ifFalse:[nil -> self].!
>>>
>>
>> See Environment>>associationAt: aSymbol ifAbsent: aBlock
>> "Senders of this should probably be using #bindingOf:"
>> self flag: #review.
>> ^ declarations associationAt: aSymbol ifAbsent: aBlock
>>
>> So let me suggest
>>
>> Class>>binding
>> "Answer a binding for the receiver, sharing if possible"
>> (self environment bindingOf: name ifAbsent: nil) ifNotNil:
>> [:bindingOrNil|
>> bindingOrNil value == self ifTrue:
>> [^bindingOrNil]].
>> ^ClassBinding key: nil value: self
>>
>> and then gradually all those anonymous Associations in class methods will
>> disappear :-)
>>
>> _,,,^..^,,,_
>> best, Eliot
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20200916/f4eea5c4/attachment-0001.html>


More information about the Squeak-dev mailing list