Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Disjunction and inheritance
Disjunction and inheritance [message #1851971] Sun, 24 April 2022 14:51 Go to next message
John Henbergs is currently offline John HenbergsFriend
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 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher GerkingFriend
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

Re: Disjunction and inheritance [message #1851994 is a reply to message #1851989] Mon, 25 April 2022 11:06 Go to previous messageGo to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Quote:

Not necessarily super types, they can also be the same.


But it they are both the same, that means that the rule would be inheriting itself. Why would that be useful?

Same for disjunction. Why would the rule need to disjunct itself?

Thanks!
Re: Disjunction and inheritance [message #1851995 is a reply to message #1851994] Mon, 25 April 2022 11:43 Go to previous message
Christopher Gerking is currently offline Christopher GerkingFriend
Messages: 116
Registered: April 2011
Senior Member
Same types doesn't imply that it's the same mapping. You can have different mappings with identical source/target types.

mapping A::m1() : B {};
mapping A::m2() : B inherits A::m1 {};

Of course inheriting/disjuncting the same mapping is useless and should produce a syntax error.

[Updated on: Mon, 25 April 2022 11:45]

Report message to a moderator

Previous Topic:Access existing objects
Next Topic:Representing QVT-Operational transformations in XML, JSON or or any other serialized format
Goto Forum:
  


Current Time: Mon Sep 09 23:45:32 GMT 2024

Powered by FUDForum. Page generated in 0.04277 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top