[squeak-dev] The Trunk: Kernel-cmm.1113.mcz

Chris Muller asqueaker at gmail.com
Fri Sep 1 01:01:02 UTC 2017


Hi Levente,

#setPinned: is a private method that provides a physical kind of
access to the object, whereas #pinned: is public, conforms to expected
naming conventions and allows (proper) overriding.  It provides a
logical (abstract) kind of access to #setPinned: as do #pin and
#unpin.

I'd recommend using #pin and #unpin if wherever possible, but there
have been enough cases where various method pairs (i.e., #lock/unlock,
#show/hide, #action/unaction, etc.) where it can't be known which one
is needed until runtime.

- Chris

On Thu, Aug 31, 2017 at 5:24 PM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> On Thu, 31 Aug 2017, commits at source.squeak.org wrote:
>
>> Chris Muller uploaded a new version of Kernel to project The Trunk:
>> http://source.squeak.org/trunk/Kernel-cmm.1113.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Kernel-cmm.1113
>> Author: cmm
>> Time: 31 August 2017, 1:55:06.158647 pm
>> UUID: 05c89229-0279-4842-b0d0-dacb2713a4b6
>> Ancestors: Kernel-tbn.1112
>>
>> Provide #pinned: so clients don't have to write duplicate code (e.g.,
>> "myCondition ifTrue: [myObject pin] ifFalse: [myObject unpin]") while
>> allowing frameworks to hook #pinned: if necessary (without overriding a
>> primitive).
>
>
> I'd like to see a use-case which justifies the existence of this method.
> I also don't see why would you use #pinned: instead of #setPinned:.
>
> Levente
>
>
>>
>> =============== Diff against Kernel-tbn.1112 ===============
>>
>> Item was changed:
>>  ----- Method: Object>>pin (in category 'pinning') -----
>>  pin
>> +       "Ensure the receiver is pinned and answer whether it was pinned."
>> +       ^ self pinned: true!
>> -       "The VM's garbage collector routinely moves objects as it reclaims
>> and compacts
>> -        memory. But it can also pin an object so that it will not be
>> moved, which can make
>> -        it easier to pass objects out through the FFI.  Objects are
>> unpinnned when created.
>> -        This method ensures an object is pinned, and answers whether it
>> was already pinned."
>> -       ^self setPinned: true!
>>
>> Item was added:
>> + ----- Method: Object>>pinned: (in category 'pinning') -----
>> + pinned: aBoolean
>> +       "The VM's garbage collector routinely moves objects as it reclaims
>> and compacts memory. But it can also pin an object so that it will not be
>> moved, which can make it easier to pass objects out through the FFI.
>> Objects are unpinnned when created.
>> +       Answer whether the receiver was pinned."
>> +       ^ self setPinned: aBoolean!
>>
>> Item was changed:
>>  ----- Method: Object>>setPinned: (in category 'private') -----
>>  setPinned: aBoolean
>> +       "Primitive which pins or unpins the receiver and answers whether
>> it was already pinned."
>> -       "The VM's garbage collector routinely moves objects as it reclaims
>> and compacts
>> -        memory. But it can also pin an object so that it will not be
>> moved, which can make
>> -        it easier to pass objects out through the FFI.  Objects are
>> unpinnned when created.
>> -        This primitive either pins or unpins an object, and answers if it
>> was already pinned."
>>         <primitive: 184 error: ec>
>>         ^self primitiveFailed!
>>
>> Item was changed:
>>  ----- Method: Object>>unpin (in category 'pinning') -----
>>  unpin
>> +       "Ensure the receiver is unpinned and answer whether it was
>> pinned."
>> +       ^ self pinned: false!
>> -       "The VM's garbage collector routinely moves objects as it reclaims
>> and compacts
>> -        memory. But it can also pin an object so that it will not be
>> moved, which can make
>> -        it easier to pass objects out through the FFI.  Objects are
>> unpinnned when created.
>> -        This method ensures an object is unpinned, and answers whether it
>> was pinned."
>> -       ^self setPinned: false!
>
>


More information about the Squeak-dev mailing list