On Oct 19, 2010, at 1:14 PM, St�phane Ducasse wrote:
> Hi mariano
>
> I do not really like your solution. Implementing flushCache is not that bad in your class. It is not a bad compromise.
> May be it should be better documented.
>
> Stef
>
>
>> When you are using Objects as methods, MethodWrappers, or whatever with run:with:in, you have to implement not only �that method, but also flushCache doing nothing because it is used in:
>>
>> MethodDictionary >> at: put:
>>
>> at: key put: value
>> � �"Set the value at key to be value."
>> � �| index |
>> � �index := self findElementOrNil: key.
>> � �(self basicAt: index) == nil
>> � � � �ifTrue:
>> � � � � � �[tally := tally + 1.
>> � � � � � �self basicAt: index put: key]
>> � � � �ifFalse:
>> � � � � � �[(array at: index) flushCache].
>> � �array at: index put: value.
>> � �self fullCheck.
>> � �^ value
>>
>>
>> Ok, I can implement that in my classes, and in MethodWrappers, but I think it would be nicer and cleanly if you only have to implement run:with:in: �since flushChache doesn't make sense for normal objects.
>>
>> So, I would like to change that code to
>>
>> at: key put: value
>> � �"Set the value at key to be value."
>> � �| index |
>> � �index := self findElementOrNil: key.
>> � �(self basicAt: index) == nil
>> � � � �ifTrue:
>> � � � � � �[tally := tally + 1.
>> � � � � � �self basicAt: index put: key]
>> � � � �ifFalse:
>> � � � � � �[(array at: index) isCompiledMethod ifTrue: [flushCache]].
>> � �array at: index put: value.
>> � �self fullCheck.
>> � �^ value
>>
>>
>> Yes, yes, I know the if is ugly, but it gives us a cleaner way to define objects as methods.
>> The other option is to implement flushCache in Object doing nothing but I like it less than this.
>>
>> opinions?
>>
>> thanks
>>
>> mariano
>> _______________________________________________
>> Pharo-project mailing list
>>
Pharo-project@lists.gforge.inria.fr
>>
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
>
Pharo-project@lists.gforge.inria.fr
>
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project