[ATL] I do not understand rule inheritance [message #535699] |
Tue, 25 May 2010 06:20  |
Eclipse User |
|
|
|
Hello,
The user guide for rule inheritance is not very clear to me.
here is the pb
IN!A is not an abstract class
IN!B inherits from IN!A
rule RuleA {
from s : IN!A (s.oclIsOfType(IN!A))
to [toA]
do [doA]
}
rule RuleB extends RuleA{
from s: IN!B
to [toB]
}
this seems to working fine, but if I change
from s: IN!B
to
from s: IN!B (s.oclIsOfType(IN!B))
I do not have any more matches ??????
I do not understand why ?
because if I create a Rule C
rule RuleC extends RuleB{
from s: IN!C
to [toC]
}
where IN!C inherits from IN!B I am afraid that this raises a multiple matching problem.
Any idea on solving this problem?
Thanks.
|
|
|
|
|
Re: [ATL] I do not understand rule inheritance [message #535793 is a reply to message #535787] |
Tue, 25 May 2010 12:43  |
Eclipse User |
|
|
|
Le 25/05/2010 18:09, seb.fr a écrit :
> Are you sure that
> from s : IN!A is equivalent to
> s.oclIsOfType(IN!A)
> because looking at the Wiki user guide, it says otherwise (
> http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#AT L_Tips_.26_Tricks
> )
> The user guide seems to say it is equivalent to
> s.oclIsOfKind(IN!A)
>
Sorry. I do not investigate enough :-(
When you define the super rule using oclIsOfType, you put the same
constraint on sub rules. In your case it means they can only apply on A
types not B or C ones....
I do not used inheritance many times but the parser manages the
differences and distributes matches on appropriate rule without multiple
matches error...
> I really am confused now 8o
>
> Vincent MAHE wrote on Tue, 25 May 2010 17:42
>> Le 25/05/2010 12:20, seb.fr a écrit :
>> > Hello,
>> > The user guide for rule inheritance is not very clear to me.
>> > here is the pb
>> >
>> > IN!A is not an abstract class IN!B inherits from IN!A
>> >
>> > rule RuleA {
>> > from s : IN!A ()
>>
>> from s : IN!A just represents the constraint s.oclIsOfType(IN!A)
>> so you do not need to specify it
>> > to [toA]
>> > do [doA]
>> > }
>> > rule RuleB extends RuleA{
>> > from s: IN!B to [toB]
>> > }
>> >
>> > this seems to working fine, but if I change
>> > from s: IN!B to
>> > from s: IN!B (s.oclIsOfType(IN!B))
>>
>> same...
>> and inheriting rules is done by a rewriting /merge of the rule so the
>> two constraints conflict.
>> >
>> > I do not have any more matches ??????
>> > I do not understand why ?
>> > because if I create a Rule C
>> >
>> > rule RuleC extends RuleB{
>> > from s: IN!C to [toC]
>>
>> ruleC will only match IN!C instances....
>> > }
>> >
>> > where IN!C inherits from IN!B I am afraid that this raises a multiple
>> > matching problem.
>> > Any idea on solving this problem?
>> >
>> > Thanks.
>>
>>
>> --
>> Cordialement
>>
>> Vincent MAHÉ
>>
>> Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
>> École des Mines de Nantes
>> La Chantrerie - 4, rue Alfred Kastler
>> B.P. 20722 - F-44307 NANTES Cedex 3
>> Tel: (33)2 51 85 81 00
>
>
--
Cordialement
Vincent MAHÉ
Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
|
|
|
Powered by
FUDForum. Page generated in 0.05029 seconds