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

Eliot Miranda eliot.miranda at gmail.com
Fri Sep 1 15:23:41 UTC 2017



> On Sep 1, 2017, at 1:18 AM, Levente Uzonyi <leves at caesar.elte.hu> wrote:
> 
> Hi Chris,
> 
>> On Thu, 31 Aug 2017, Chris Muller wrote:
>> 
>> 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.
> 
> It doesn't matter if it's private or not, because that can be changed.
> What I don't understand is the need for an additional wrapper method.
> If you think #pinned: is needed, then it should replace #setPinned:.

+1

>> 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.
> 
> I just can't imagine a real-world situation where you'd want to pin or unpin an object based on a condition.

+0.75. There could be circumstances (select the pinned state of a subset of arguments and flip their pinning after a call perhaps?) but given the need to u pin isn't pressing I think you're right Levente.

So given that the useful public protocol is isPinned, pin & unpin, the ugliness of the private setPinned: is neither here nor there and pinned: is unnecessary.  I would revert this.  

On the Pharo list Denis brings up a much more pertinent issue, whether pin status al are too generic.  Pavel suggests
     isPinnedInMemory
     pinInMemory
     unpinInMemory

> 
> Levente
> 
>> 
>> - 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