Slots in Pharo 5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Slots in Pharo 5

Jan Čada-2
Hi, 

I started to play with slots and I am observing odd behaviour after the class structure gets changed. 

I am having classes:

Object subclass: #CTA
slots: { #x. #b => ToManyRelationSlot inverse: #a inClass: #CTB }
classVariables: {  }
category: ‘ClassTest'

and 

Object subclass: #CTB
slots: { #x. #a => ToOneRelationSlot inverse: #b inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

then I create instance of CTA and CTB pointing to CTA:

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

the a1 is updated as expected with b having RelationSet with my CTB instance. 

The problem is when I decided to update the class CTA - changing position of slot   #b => ToManyRelationSlot inverse: #a inClass: #CTB. 
In the case I drop all the instances of CTA and CTB and recreate new by code above, the inverse update always addresses slot on same position as before  and not the one with right name.

For example when I change it like :

Object subclass: #CTA
slots: { #x. #children => ToManyRelationSlot inverse: #parent inClass: #CTA
#b => ToManyRelationSlot inverse: #a inClass: #CTB
#parent => ToOneRelationSlot inverse: #children inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

the result of the code 

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

is that slot children gets updated having RelationSet with my CTB instance instead of slot b which has empty RelationSet.

The question is: Am I doing something wrong ? Is there any way how to tell class to reinit slots as its order has changed ?

Thanks, 

Jan

 
Reply | Threaded
Open this post in threaded view
|

Re: Slots in Pharo 5

Jan Čada-2
Hi, 

I investigated a little bit more and I see that 

CTA slots are as expected - slot b has index 3:



while CTB slots have inverse slot for a with old index 2  - so the inverse part was not updated when I changed CTA structure


Thanks for any advice, 

Jan


On 28 Sep 2016, at 15:36, Jan Cada <[hidden email]> wrote:

Hi, 

I started to play with slots and I am observing odd behaviour after the class structure gets changed. 

I am having classes:

Object subclass: #CTA
slots: { #x. #b => ToManyRelationSlot inverse: #a inClass: #CTB }
classVariables: {  }
category: ‘ClassTest'

and 

Object subclass: #CTB
slots: { #x. #a => ToOneRelationSlot inverse: #b inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

then I create instance of CTA and CTB pointing to CTA:

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

the a1 is updated as expected with b having RelationSet with my CTB instance. 

The problem is when I decided to update the class CTA - changing position of slot   #b => ToManyRelationSlot inverse: #a inClass: #CTB. 
In the case I drop all the instances of CTA and CTB and recreate new by code above, the inverse update always addresses slot on same position as before  and not the one with right name.

For example when I change it like :

Object subclass: #CTA
slots: { #x. #children => ToManyRelationSlot inverse: #parent inClass: #CTA
#b => ToManyRelationSlot inverse: #a inClass: #CTB
#parent => ToOneRelationSlot inverse: #children inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

the result of the code 

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

is that slot children gets updated having RelationSet with my CTB instance instead of slot b which has empty RelationSet.

The question is: Am I doing something wrong ? Is there any way how to tell class to reinit slots as its order has changed ?

Thanks, 

Jan

 

Reply | Threaded
Open this post in threaded view
|

Re: Slots in Pharo 5

Denis Kudriashov
In reply to this post by Jan Čada-2
Hi.

It looks like bug. Could you open issue?

2016-09-28 15:36 GMT+02:00 Jan Cada <[hidden email]>:
Hi, 

I started to play with slots and I am observing odd behaviour after the class structure gets changed. 

I am having classes:

Object subclass: #CTA
slots: { #x. #b => ToManyRelationSlot inverse: #a inClass: #CTB }
classVariables: {  }
category: ‘ClassTest'

and 

Object subclass: #CTB
slots: { #x. #a => ToOneRelationSlot inverse: #b inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

then I create instance of CTA and CTB pointing to CTA:

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

the a1 is updated as expected with b having RelationSet with my CTB instance. 

The problem is when I decided to update the class CTA - changing position of slot   #b => ToManyRelationSlot inverse: #a inClass: #CTB. 
In the case I drop all the instances of CTA and CTB and recreate new by code above, the inverse update always addresses slot on same position as before  and not the one with right name.

For example when I change it like :

Object subclass: #CTA
slots: { #x. #children => ToManyRelationSlot inverse: #parent inClass: #CTA
#b => ToManyRelationSlot inverse: #a inClass: #CTB
#parent => ToOneRelationSlot inverse: #children inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

the result of the code 

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

is that slot children gets updated having RelationSet with my CTB instance instead of slot b which has empty RelationSet.

The question is: Am I doing something wrong ? Is there any way how to tell class to reinit slots as its order has changed ?

Thanks, 

Jan

 

Reply | Threaded
Open this post in threaded view
|

Re: Slots in Pharo 5

Jan Čada-2
Hi, 

I have opened the issue #19153

Thanks, 

Jan

On 28 Sep 2016, at 16:10, Denis Kudriashov <[hidden email]> wrote:

Hi.

It looks like bug. Could you open issue?

2016-09-28 15:36 GMT+02:00 Jan Cada <[hidden email]>:
Hi, 

I started to play with slots and I am observing odd behaviour after the class structure gets changed. 

I am having classes:

Object subclass: #CTA
slots: { #x. #b => ToManyRelationSlot inverse: #a inClass: #CTB }
classVariables: {  }
category: ‘ClassTest'

and 

Object subclass: #CTB
slots: { #x. #a => ToOneRelationSlot inverse: #b inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

then I create instance of CTA and CTB pointing to CTA:

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

the a1 is updated as expected with b having RelationSet with my CTB instance. 

The problem is when I decided to update the class CTA - changing position of slot   #b => ToManyRelationSlot inverse: #a inClass: #CTB. 
In the case I drop all the instances of CTA and CTB and recreate new by code above, the inverse update always addresses slot on same position as before  and not the one with right name.

For example when I change it like :

Object subclass: #CTA
slots: { #x. #children => ToManyRelationSlot inverse: #parent inClass: #CTA
#b => ToManyRelationSlot inverse: #a inClass: #CTB
#parent => ToOneRelationSlot inverse: #children inClass: #CTA }
classVariables: {  }
category: ‘ClassTest'

the result of the code 

a1 := CTA new x: 1; yourself.
b1 := CTB new x: 1; a: a1; yourself.

is that slot children gets updated having RelationSet with my CTB instance instead of slot b which has empty RelationSet.

The question is: Am I doing something wrong ? Is there any way how to tell class to reinit slots as its order has changed ?

Thanks, 

Jan

 


Reply | Threaded
Open this post in threaded view
|

Re: Slots in Pharo 5

Denis Kudriashov

2016-09-28 17:06 GMT+02:00 Jan Cada <[hidden email]>:
Hi, 

I have opened the issue #19153

Thank's