Christoph Thiede uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-ct.1553.mcz
==================== Summary ====================
Name: Kernel-ct.1553 Author: ct Time: 24 February 2024, 8:42:15.180459 pm UUID: bfcd6789-4af9-cc41-8278-5a27709723d5 Ancestors: Kernel-mt.1551, Kernel-ct.1293
Merges and revises Kernel-ct.1293: Elaborate method comment in Object >> #copyFrom:
See: https://lists.squeakfoundation.org/archives/list/squeak-dev@lists.squeakfoun...
=============== Diff against Kernel-mt.1551 ===============
Item was changed: ----- Method: CompiledCode>>copyFrom: (in category 'copying') ----- copyFrom: anotherObject + "Copy to myself all slots I have in common with anotherObject, i.e., all variables names which have the same index in both classes and all element indices which are available in both classes. + This is dangerous because it ignores an object's control over its own inst vars." - "Copy to myself all instance variables I have in common with anotherObject. - This is dangerous because it ignores an object's control over its own inst vars."
<primitive: 168> anotherObject isCompiledCode ifTrue: [1 to: self numLiterals do: [:i| self literalAt: i put: (anotherObject literalAt: i)]] ifFalse: [1 to: self numLiterals do: [:i| self literalAt: i put: (anotherObject at: i)]]. self initialPC to: (self basicSize min: anotherObject basicSize) do: [:i| self basicAt: i put: (anotherObject basicAt: i)]!
Item was changed: ----- Method: Object>>copyFrom: (in category 'copying') ----- copyFrom: anotherObject + "Copy to myself all slots I have in common with anotherObject, i.e., all variables names which have the same index in both classes and all element indices which are available in both classes. + This is dangerous because it ignores an object's control over its own inst vars." - "Copy to myself all instance variables I have in common with anotherObject. This is dangerous because it ignores an object's control over its own inst vars. "
| mine his | <primitive: 168> mine := self class allInstVarNames. his := anotherObject class allInstVarNames. 1 to: (mine size min: his size) do: [:ind | (mine at: ind) = (his at: ind) ifTrue: [ self instVarAt: ind put: (anotherObject instVarAt: ind)]]. self class isVariable & anotherObject class isVariable ifTrue: [ 1 to: (self basicSize min: anotherObject basicSize) do: [:ind | self basicAt: ind put: (anotherObject basicAt: ind)]].!
Item was changed: ----- Method: Object>>copySameFrom: (in category 'copying') ----- copySameFrom: otherObject "Copy to myself all instance variables named the same in otherObject. + This is dangerous because it ignores an object's control over its own inst vars." - This ignores otherObject's control over its own inst vars."
| myInstVars otherInstVars | myInstVars := self class allInstVarNames. otherInstVars := otherObject class allInstVarNames. myInstVars withIndexDo: [:each :index | | match | (match := otherInstVars indexOf: each) > 0 ifTrue: [self instVarAt: index put: (otherObject instVarAt: match)]]. 1 to: (self basicSize min: otherObject basicSize) do: [:i | self basicAt: i put: (otherObject basicAt: i)]. !
Hi Christoph,
On Feb 24, 2024, at 11:42 AM, commits@source.squeak.org wrote:
Christoph Thiede uploaded a new version of Kernel to project The Trunk: http://source.squeak.org/trunk/Kernel-ct.1553.mcz
==================== Summary ====================
Name: Kernel-ct.1553 Author: ct Time: 24 February 2024, 8:42:15.180459 pm UUID: bfcd6789-4af9-cc41-8278-5a27709723d5 Ancestors: Kernel-mt.1551, Kernel-ct.1293
Merges and revises Kernel-ct.1293: Elaborate method comment in Object >> #copyFrom:
See: https://lists.squeakfoundation.org/archives/list/squeak-dev@lists.squeakfoun...
=============== Diff against Kernel-mt.1551 ===============
Item was changed: ----- Method: CompiledCode>>copyFrom: (in category 'copying') ----- copyFrom: anotherObject
- "Copy to myself all slots I have in common with anotherObject, i.e., all variables names which have the same index in both classes and all element indices which are available in both classes.
- This is dangerous because it ignores an object's control over its own inst vars."
"Copy to myself all instance variables I have in common with anotherObject.
This is dangerous because it ignores an object's control over its own inst vars."
<primitive: 168> anotherObject isCompiledCode ifTrue: [1 to: self numLiterals do: [:i| self literalAt: i put: (anotherObject literalAt: i)]] ifFalse: [1 to: self numLiterals do: [:i| self literalAt: i put: (anotherObject at: i)]]. self initialPC to: (self basicSize min: anotherObject basicSize) do: [:i| self basicAt: i put: (anotherObject basicAt: i)]!
If used on methods containing full blocks this will generate invalid methods where the full block methods within them won’t refer to the method into which they are copied via copyFrom:. I’m just nothing this. I think it should be in the comment. There may be circumstances in which copyFrom: might be useful with CompiledCode (but I doubt it) but in most cases it would be dangerous.
Eliot _,,,^..^,,,_ (phone)
Item was changed: ----- Method: Object>>copyFrom: (in category 'copying') ----- copyFrom: anotherObject
- "Copy to myself all slots I have in common with anotherObject, i.e., all variables names which have the same index in both classes and all element indices which are available in both classes.
- This is dangerous because it ignores an object's control over its own inst vars."
"Copy to myself all instance variables I have in common with anotherObject. This is dangerous because it ignores an object's control over its own inst vars. "
| mine his | <primitive: 168> mine := self class allInstVarNames. his := anotherObject class allInstVarNames. 1 to: (mine size min: his size) do: [:ind | (mine at: ind) = (his at: ind) ifTrue: [ self instVarAt: ind put: (anotherObject instVarAt: ind)]]. self class isVariable & anotherObject class isVariable ifTrue: [ 1 to: (self basicSize min: anotherObject basicSize) do: [:ind | self basicAt: ind put: (anotherObject basicAt: ind)]].!
Item was changed: ----- Method: Object>>copySameFrom: (in category 'copying') ----- copySameFrom: otherObject "Copy to myself all instance variables named the same in otherObject.
- This is dangerous because it ignores an object's control over its own inst vars."
This ignores otherObject's control over its own inst vars."
| myInstVars otherInstVars | myInstVars := self class allInstVarNames. otherInstVars := otherObject class allInstVarNames. myInstVars withIndexDo: [:each :index | | match | (match := otherInstVars indexOf: each) > 0 ifTrue: [self instVarAt: index put: (otherObject instVarAt: match)]]. 1 to: (self basicSize min: otherObject basicSize) do: [:i | self basicAt: i put: (otherObject basicAt: i)].
!
squeak-dev@lists.squeakfoundation.org