Disjunction and inheritance [message #1851971] |
Sun, 24 April 2022 14:51 |
John Henbergs Messages: 239 Registered: October 2020 |
Senior Member |
|
|
Hi,
I was wondering about the rules of the signature conformance when it comes to inheritance and disjunction.
From what I understand, in the case of inheritance, if we have the following mappings:
mapping sourceA :: mappingA() : targetA{
...
}
mapping sourceB :: mappingB() : targetB
inherits mappingA()
{
}
mapping B inherits mapping A in the following conditions:
- Either sourceA or targetA is a super type of sourceB or targetB respectively.
- They can both be super types (source and target), but even if only one of them is (e.g., only sourceA is a super type of sourceB), targetA should at least be the same as targetB.
In the case of disjunction:
mapping sourceA :: mappingA() : targetA{
...
}
mapping sourceB :: mappingB() : targetB{
...
}
mapping sourceC :: mappingC() : targetC
disjuncts mappingA, mappingB
{
}
mappingA is a disjuncted mapping if :
- targetA is not abstract,
- - Either sourceA or targetA is a subtype of sourceC or targetC respectively.
- They can both be subtypes (source and target), but even if only one of them is (e.g., only sourceA is a subtype of sourceC), targetA should at least be the same as targetC.
Are these cases correct? And could there be other cases where I should use inheritance and disjunction (with respect to signature conformance)?
Thank you!
|
|
|
Re: Disjunction and inheritance [message #1851989 is a reply to message #1851971] |
Mon, 25 April 2022 09:15 |
Christopher Gerking Messages: 116 Registered: April 2011 |
Senior Member |
|
|
Hi John
Both disjunction and inheritance are supported by Eclipse QVTo. Did you try to implement your cases? The syntax check of the QVTo editor will tell you exactly which signatures are conforming and which not.
John Henbergs wrote on Sun, 24 April 2022 10:51
mapping B inherits mapping A in the following conditions:
- Either sourceA or targetA is a super type of sourceB or targetB respectively.
Not necessarily super types, they can also be the same.
John Henbergs wrote on Sun, 24 April 2022 10:51
- They can both be super types (source and target), but even if only one of them is (e.g., only sourceA is a super type of sourceB), targetA should at least be the same as targetB.
Why? I don't understand that rule. You can also use inheritance between two mappings with the exact same source and target types.
The principle you are looking for is covariance. In case of inheritance, sourceB and targetB must be covariant, meaning that they are subtypes of sourceA and targetA. They can also be invariant, meaning that they are the same.
John Henbergs wrote on Sun, 24 April 2022 10:51
mappingA is a disjuncted mapping if :
- targetA is not abstract,
Why not? targetA can surely be abstract, for example if mappingA is itself disjunctive or has an init section.
John Henbergs wrote on Sun, 24 April 2022 10:51
- - Either sourceA or targetA is a subtype of sourceC or targetC respectively.
Again, they don't have to be subtypes. The types could also be exactly the same.
Here the underlying principle is contravariance. In case of disjunction, sourceC and targetC must be contravariant, meaning that they are supertypes of sourceA and targetA and, respectively, supertypes of sourceB and targetB. Again they can also be invariant.
Kind regards
Christopher
[Updated on: Mon, 25 April 2022 09:17] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04277 seconds