> On 27 Feb 2015, at 5:43 , Guillermo Polito <[email protected]> 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
> <[email protected] <mailto:[email protected]>> escribió:
>
>> On 26 Feb 2015, at 6:55 , Guillermo Polito <[email protected]
>> <mailto:[email protected]>> 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