The Trunk: Kernel-cmm.1113.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Kernel-cmm.1113.mcz

commits-2
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).

=============== 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!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

Levente Uzonyi
On Thu, 31 Aug 2017, [hidden email] 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!

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

Chris Muller-3
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 <[hidden email]> wrote:

> On Thu, 31 Aug 2017, [hidden email] 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!
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

Eliot Miranda-2
In reply to this post by commits-2
Why?  This extra method adds nothing but overhead.

_,,,^..^,,,_ (phone)

> On Aug 31, 2017, at 10:55 AM, [hidden email] 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).
>
> =============== 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!
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

marcel.taeumel
In reply to this post by Chris Muller-3
+1

#setPinned: looks like it is coming from C land or Java land. :) #pinned:, #pin, and #unpin are more idiomatic for Smalltalk code.

Best,
Marcel

Am 01.09.2017 03:01:55 schrieb Chris Muller <[hidden email]>:

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 wrote:

> On Thu, 31 Aug 2017, [hidden email] 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."
>>
>> ^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!
>
>



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

Levente Uzonyi
In reply to this post by Chris Muller-3
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:.

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

Levente

>
> - Chris
>
> On Thu, Aug 31, 2017 at 5:24 PM, Levente Uzonyi <[hidden email]> wrote:
>> On Thu, 31 Aug 2017, [hidden email] 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!
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

Eliot Miranda-2


> On Sep 1, 2017, at 1:18 AM, Levente Uzonyi <[hidden email]> 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 <[hidden email]> wrote:
>>>> On Thu, 31 Aug 2017, [hidden email] 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!
>>>
>>>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

Eliot Miranda-2
In reply to this post by marcel.taeumel


On Aug 31, 2017, at 11:57 PM, Marcel Taeumel <[hidden email]> wrote:

+1

#setPinned: looks like it is coming from C land or Java land. :) #pinned:, #pin, and #unpin are more idiomatic for Smalltalk code.

I struggle NFL time disagree.  setPinned: is a low level interface to the VM, not user API.  isPinned, pin & unpin are the user API.  And as mentioned elsewhere these might better be named isPinnedInMemory, pinInMemory & unpinInMemory.


Best,
Marcel

Am 01.09.2017 03:01:55 schrieb Chris Muller <[hidden email]>:

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 wrote:

> On Thu, 31 Aug 2017, [hidden email] 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."
>>
>> ^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!
>
>




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Kernel-cmm.1113.mcz

Chris Muller-3
In reply to this post by Levente Uzonyi
> 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.

I suppose you could make this same argument against #pin and #unpin.

> If you think #pinned: is needed, then it should replace #setPinned:.

The separation here was due only to the fact that setPinned: is a
lever that rests directly against the "metal" and I think its
preferable to insulate user-level API's from that.

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

What about #isPinned?  Can you imagine a situation where you'd ever
need that?  Maybe should remove that one too?  And why does the
primitive need to answer whether it *was* pinned?

I think a robustly-designed API becomes more possible when think about
possible usages beyond FFI calls.

I once thought I would never need to call "Smalltalk garbageCollect"
but, eventually, in one app I ran into a scaling issue where I
actually needed to do it to improve performance.

Having said all this, I have had times when I've wanted to purposely
restrict an API to one specific use-case, and require code changes for
it to grow beyond that use-case, so as to force proper consideration.

I went ahead and reverted my changes.

Reply | Threaded
Open this post in threaded view
|

Naming things (was Re: The Trunk: Kernel-cmm.1113.mcz)

timrowledge
In reply to this post by Eliot Miranda-2

> On 01-09-2017, at 8:23 AM, Eliot Miranda <[hidden email]> wrote:
>
> On the Pharo list Denis brings up a much more pertinent issue, whether pin status al are too generic.  Pavel suggests
>     isPinnedInMemory
>     pinInMemory
>     unpinInMemory

I’d tend to agree with Dennis; short and pithy names seem a good idea initially but rarely offer much of a clue as to what the hell the message does. Which makes reading code that uses said message less illuminating than it could be.

It’s like project & class naming. If you want your project named ‘sponson’ because it tickles your fancy to name it something to do with storage then go for it (but always be aware that names usually have many meanings - sponsons are also stability outriggers, mounting points etc) but for goodness’ sake don’t name all your classes in a similarly obtuse manner. Names should be something  that helps us.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
The colder the X-ray table, the more of your body is required on it.