Slots: and ProcessLocalSlot
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing. Example of usage: Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'. object := TestLocal new. object local: 55. object local. [ valueInOtherProcess := object local ] fork. valueInOtherProcess. "=> nil" [ object local: 'String'. valueInOtherProcess := object local ] fork. valueInOtherProcess. "=> 'String'" object local "=> 55" Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot Guille
*Very* nice !
On 26 Feb 2015, at 18:55, Guillermo Polito <guillermopolito@gmail.com> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot
Guille
Very very nice! This is really cool. Doru On Thu, Feb 26, 2015 at 7:01 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
*Very* nice !
On 26 Feb 2015, at 18:55, Guillermo Polito <guillermopolito@gmail.com> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot
Guille
-- www.tudorgirba.com "Every thing has its own flow"
First of all, the things that you are doing with slots are just amazing. I never thought that there were so many cool stuff that could be done with them. Now, two things to point out about the ProcessLocalSlot that probably not all know. 1) The value is stored weakly, an example of this would be: obj := MyClass new. obj local: Object new. obj local. âanObjectâ <ââ Now we see the object Smalltalk garbageCollect. obj local. ânilâ <ââ Now we donât 2) This variable are stored in a WeakArray in the Process, so massive use of them will make the array in the processes start growing a lot and often. Use them wisely :) Again, really cool stuff. Thanks Guille!!! Cheers, Alejandro
On Feb 26, 2015, at 10:32 PM, Tudor Girba <tudor@tudorgirba.com> wrote:
Very very nice!
This is really cool.
Doru
On Thu, Feb 26, 2015 at 7:01 PM, Sven Van Caekenberghe <sven@stfx.eu <mailto:sven@stfx.eu>> wrote: *Very* nice !
On 26 Feb 2015, at 18:55, Guillermo Polito <guillermopolito@gmail.com <mailto:guillermopolito@gmail.com>> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot <https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot>
Guille
-- www.tudorgirba.com <http://www.tudorgirba.com/>
"Every thing has its own flow"
Haha, I didn't know that. I'll add that in the class comment. El Fri Feb 27 2015 at 11:23:59 AM, Alejandro Infante < alejandroinfante91@gmail.com> escribió:
First of all, the things that you are doing with slots are just amazing. I never thought that there were so many cool stuff that could be done with them.
Now, two things to point out about the ProcessLocalSlot that probably not all know.
1) The value is stored weakly, an example of this would be: obj := MyClass new. obj local: Object new. obj local. âanObjectâ <ââ Now we see the object Smalltalk garbageCollect. obj local. ânilâ <ââ Now we donât
2) This variable are stored in a WeakArray in the Process, so massive use of them will make the array in the processes start growing a lot and often. Use them wisely :)
Again, really cool stuff. Thanks Guille!!!
Cheers, Alejandro
On Feb 26, 2015, at 10:32 PM, Tudor Girba <tudor@tudorgirba.com> wrote:
Very very nice!
This is really cool.
Doru
On Thu, Feb 26, 2015 at 7:01 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
*Very* nice !
On 26 Feb 2015, at 18:55, Guillermo Polito <guillermopolito@gmail.com> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot
Guille
-- www.tudorgirba.com
"Every thing has its own flow"
Done https://pharo.fogbugz.com/f/cases/15007/Add-comment-on-ProcessLocalSlot-for-... El Fri Feb 27 2015 at 11:31:55 AM, Guillermo Polito < guillermopolito@gmail.com> escribió:
Haha, I didn't know that. I'll add that in the class comment.
El Fri Feb 27 2015 at 11:23:59 AM, Alejandro Infante < alejandroinfante91@gmail.com> escribió:
First of all, the things that you are doing with slots are just amazing. I
never thought that there were so many cool stuff that could be done with them.
Now, two things to point out about the ProcessLocalSlot that probably not all know.
1) The value is stored weakly, an example of this would be: obj := MyClass new. obj local: Object new. obj local. âanObjectâ <ââ Now we see the object Smalltalk garbageCollect. obj local. ânilâ <ââ Now we donât
2) This variable are stored in a WeakArray in the Process, so massive use of them will make the array in the processes start growing a lot and often. Use them wisely :)
Again, really cool stuff. Thanks Guille!!!
Cheers, Alejandro
On Feb 26, 2015, at 10:32 PM, Tudor Girba <tudor@tudorgirba.com> wrote:
Very very nice!
This is really cool.
Doru
On Thu, Feb 26, 2015 at 7:01 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
*Very* nice !
On 26 Feb 2015, at 18:55, Guillermo Polito <guillermopolito@gmail.com> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add- ProcessLocalSlot
Guille
-- www.tudorgirba.com
"Every thing has its own flow"
Great catch. Thanks. Doru On Fri, Feb 27, 2015 at 11:23 AM, Alejandro Infante < alejandroinfante91@gmail.com> wrote:
First of all, the things that you are doing with slots are just amazing. I never thought that there were so many cool stuff that could be done with them.
Now, two things to point out about the ProcessLocalSlot that probably not all know.
1) The value is stored weakly, an example of this would be: obj := MyClass new. obj local: Object new. obj local. âanObjectâ <ââ Now we see the object Smalltalk garbageCollect. obj local. ânilâ <ââ Now we donât
2) This variable are stored in a WeakArray in the Process, so massive use of them will make the array in the processes start growing a lot and often. Use them wisely :)
Again, really cool stuff. Thanks Guille!!!
Cheers, Alejandro
On Feb 26, 2015, at 10:32 PM, Tudor Girba <tudor@tudorgirba.com> wrote:
Very very nice!
This is really cool.
Doru
On Thu, Feb 26, 2015 at 7:01 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
*Very* nice !
On 26 Feb 2015, at 18:55, Guillermo Polito <guillermopolito@gmail.com> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot
Guille
-- www.tudorgirba.com
"Every thing has its own flow"
-- www.tudorgirba.com "Every thing has its own flow"
On 26 Feb 2015, at 6:55 , Guillermo Polito <guillermopolito@gmail.com> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot <https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot>
Guille
Pardon my ignorance, but can Slot definitions be composed like traits? Because I can imagine wanting, say ProcessLocal + mmm... Static, without having to combine the two properties in a class with a gnarly inheritance tree, or a factorial number of classes combining different defining traits... Cheers, Henry
Not yet, but that is a next step we were discussing the other day. El Fri Feb 27 2015 at 5:41:50 PM, Henrik Johansen < henrik.s.johansen@veloxit.no> escribió:
On 26 Feb 2015, at 6:55 , Guillermo Polito <guillermopolito@gmail.com> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot
Guille
Pardon my ignorance, but can Slot definitions be composed like traits? Because I can imagine wanting, say ProcessLocal + mmm... Static, without having to combine the two properties in a class with a gnarly inheritance tree, or a factorial number of classes combining different defining traits...
Cheers, Henry
On 27 Feb 2015, at 5:43 , Guillermo Polito <guillermopolito@gmail.com> wrote:
Not yet, but that is a next step we were discussing the other day.
El Fri Feb 27 2015 at 5:41:50 PM, Henrik Johansen <henrik.s.johansen@veloxit.no <mailto:henrik.s.johansen@veloxit.no>> escribió:
On 26 Feb 2015, at 6:55 , Guillermo Polito <guillermopolito@gmail.com <mailto:guillermopolito@gmail.com>> wrote:
So I added an example of ProcessLocalSlot (like a thread local from other languages) using the existing ProcessLocalVariable. A variable has different values depending on the process the code is executing.
Example of usage:
Object subclass: #TestLocal slots: { #local => ProcessLocalSlot } classVariables: { } category: 'SlotTestGuille'.
object := TestLocal new. object local: 55. object local.
[ valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> nil"
[ object local: 'String'. valueInOtherProcess := object local ] fork.
valueInOtherProcess. "=> 'String'" object local "=> 55"
Code in issue: https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot <https://pharo.fogbugz.com/f/cases/15004/Add-ProcessLocalSlot>
Guille
Pardon my ignorance, but can Slot definitions be composed like traits? Because I can imagine wanting, say ProcessLocal + mmm... Static, without having to combine the two properties in a class with a gnarly inheritance tree, or a factorial number of classes combining different defining traits...
Cheers, Henry
Looking forward to it! Would something like slots: {#x . #y . #area -> (Cache: #calculateArea)) } Meaning :area is a Slot that holds a cached value, calculated when accessed (by calling calculateArea), and nilled whenever slots accessed by it's calculation method takes a new value. be possible as well? Who said cache invalidation has to be hard? ;) Cheers, Henry
On 27 Feb 2015, at 17:53, Henrik Johansen <henrik.s.johansen@veloxit.no> wrote:
Would something like slots: {#x . #y . #area -> (Cache: #calculateArea)) }
Meaning :area is a Slot that holds a cached value, calculated when accessed (by calling calculateArea), and nilled whenever slots accessed by it's calculation method takes a new value.
yes, that should be quite easy to build in combination with MetaLinks⦠Marcus
Pardon my ignorance, but can Slot definitions be composed like traits?
I was wondering the same already :-) e.g. I want to be able to make any slot a hidden slot without having to subclass it.
Because I can imagine wanting, say ProcessLocal + mmm... Static, without having to combine the two properties in a class with a gnarly inheritance tree, or a factorial number of classes combining different defining traits...
The proof-of-concept for how to realise MetaLinks on Slots is using a Wrapper.. this way every slot can be annotate with a MetaLink. Maybe that can be generalised? Marcus
participants (6)
-
Alejandro Infante -
Guillermo Polito -
Henrik Johansen -
Marcus Denker -
Sven Van Caekenberghe -
Tudor Girba