[Pharo-project] about code formatting in pharo

Lukas Renggli renggli at gmail.com
Sun Feb 28 16:21:20 EST 2010

I've commented a version of RBConfigurableFormatter that can format
#copyFrom: to the following code. This comes pretty close to the
document of Adrian:

Object>>copyFrom: anotherObject
	"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>
	| mine his |
	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) ] ]

Lukas Renggli

More information about the Pharo-dev mailing list