MaClassDefinition in question

Hilaire Fernandes hilaire at ofset.org
Thu Jul 26 10:23:13 UTC 2007


Le Tue, 24 Jul 2007 22:53:58 -0400, Chris Muller a écrit:

> Hi Hilaire, sorry for the delayed response; I have just returned from a holiday.
> 
> Instances of MaClassDefinition are kept for each version of each class
> that was ever committed to the repository.
> 
> When a ReadStrategy is specified, it should work fine for the old and
> new versions of the classes.  See
> MaReadStrategy>>#convertSpecificationsToIdsUsing: to see that it does
> indeed create depth-specifications for every known version of the
> class.  The variable that does not exist in the old version will
> simply

Yes? From my analysis it seems the code is missing for this kind of
situation. See bellow.


> 
> There is no need to "remove" the instance of your domain as it evolves
> with your class model; the new variables will have nil just like
> Smalltalk until you populate them and commit.
> 
> Can you try again to explain the exact problem you are having?
> Perhaps a script that reproduces it would improve our mutual clarity?

It is not easy to track the problem (or even reproduce it in another
context), but it occures as you told from there in
convertSpecificationsToIdsUsing: exactly at (self instVarMapFor: eachDef)
in:

[ depths
	at: { eachDefinition id.  eachDefinition version } ifAbsentPut:
		[ self beNew.
		(self instVarMapFor: eachDef) ] ] ] ] ]

 
My class has 4 definitions, and pb comes with id:156, version:1., no prior
strategy is present for this version. So from then, throught: self
instVarMapFor: eachDef, Magma tries to install a readstrategy for a
variable #exerciceAtStart not present in version 1 of the class
definition (variable eachDef).

In instVarMapFor:

[ answer := self depthArrayOfSize: aMaClassDefinition namedInstSize.
	specifiedDepths keysAndValuesDo:
		[ : eachInstVarName : eachDepth |
			answer
				at: (aMaClassDefinition allInstVarNames indexOf: eachInstVarName)
				put: eachDepth ] ] ]

Here 
answer=#(0 0 0 0 0 0 0 0 0) (looks ok)

specifiedDepths=Dictionary(#exercice->999 #exerciceAtStart->999 ) (looks
ok)

but with eachInstVarName=#exerciceAtStart 

(aMaClassDefinition allInstVarNames indexOf: eachInstVarName) is 0

Indeed aMaClassDefinition is definition version 1 where exerciceAtStart
instance variable is not present.

Obviously there is a situation there.

The change to the method below prevents the error, but I really don't
know if this is the way to do it:

[:eachInstVarName :eachDepth |
	index :=  (aMaClassDefinition allInstVarNames indexOf: eachInstVarName).
	index > 0 ifTrue:
		[answer
			at: index
			put: eachDepth] ]


Hilaire



More information about the Magma mailing list