Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » [QVTO] Default initialization of * features
[QVTO] Default initialization of * features [message #870776] Wed, 09 May 2012 11:32 Go to next message
Christopher Gerking is currently offline Christopher Gerking
Messages: 39
Registered: April 2011
Member
A target EClass has a *-feature, i.e. cardinality is > 1. After instantiating the EClass within QVTO, the following queries lead to the following results:

(o.ref = null) is false, which implies that the feature has been initialized automatically

(o.ref.oclIsUndefined()) is [], which shows that oclIsUndefined does not return true or false in favor of an empty sequence. I do not assume that this is the intended behaviour?

(o.ref->size()) is 0, which makes sense


On intermediate class objects, the situation is even more weird. After creation of an intermediate class object:

(o.ref = null) is false, same behaviour as for default objects

(o.ref.oclIsUndefined()) is [true], obviously the result is a seqauence containing an instance of OclVoid

(o.ref->size()) is 1, which is normally not expected behaviour and caused serious problems in my case

Why does oclIsUndefined() return a sequence at all and why does the sequence contain an instance of OclVoid in case of an intermediate class?
Re: [QVTO] Default initialization of * features [message #870784 is a reply to message #870776] Wed, 09 May 2012 12:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

o.ref.oclIsUndefined() is a shortform for
o.ref->collect(oclIsUndefined()) so you get a (empty) collection of the
element returns.

You don't say how you create your intermediate class object so a
response is possible. I suspect you are using the implicit ->
conversion. o.ref->size() = 1 seems very sensible to me.

With QVTo you are using the Ecore binding of Eclipse OCL. This has some
problems in null/invalid/deep collection corner cases, which only
acquired a meaningful specification in OCL 2.3, which postdates QVTo 1.1.

Regards

Ed Willink

On 09/05/2012 16:33, Christopher G. wrote:
> A target EClass has a *-feature, i.e. cardinality is > 1. After
> instantiating the EClass within QVTO, the following queries lead to
> the following results:
>
> (o.ref = null) is false, which implies that the feature has been
> initialized automatically
> (o.ref.oclIsUndefined()) is [], which shows that oclIsUndefined does
> not return true or false in favor of an empty sequence. I do not
> assume that this is the intended behaviour?
>
> (o.ref->size()) is 0, which makes sense
>
>
> On intermediate class objects, the situation is even more weird. After
> creation of an intermediate class object:
>
> (o.ref = null) is false, same behaviour as for default objects
> (o.ref.oclIsUndefined()) is [true], obviously the result is a
> seqauence containing an instance of OclVoid
>
> (o.ref->size()) is 1, which is normally not expected behaviour and
> caused serious problems in my case
>
> Why does oclIsUndefined() return a sequence at all and why does the
> sequence contain an instance of OclVoid in case of an intermediate class?
Re: [QVTO] Default initialization of * features [message #870990 is a reply to message #870784] Thu, 10 May 2012 09:35 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher Gerking
Messages: 39
Registered: April 2011
Member
Edward Willink wrote on Wed, 09 May 2012 12:13
Hi

o.ref.oclIsUndefined() is a shortform for
o.ref->collect(oclIsUndefined()) so you get a (empty) collection of the
element returns.



Okay, this makes sense.


Edward Willink wrote on Wed, 09 May 2012 12:13

You don't say how you create your intermediate class object so a
response is possible. I suspect you are using the implicit ->
conversion. o.ref->size() = 1 seems very sensible to me.


Size 1 is sensible, why? The object o is created via 'object' keyword. Without explicit initialization of the ref feature, the null check returns false. Obviously, the feature has been initialized automatically. For the automatic initialization I would assume an empty collection. Instead, there seems to be an instance of OclVoid inside the collection, which implies the size 1.

The actual problem is that the OclVoid instance remains during execution, i.e. when first adding to that collection, the size is 2 and so on...



Re: [QVTO] Default initialization of * features [message #871357 is a reply to message #870990] Sat, 12 May 2012 06:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

As I wrote: You don't say how you create your intermediate class object
.... seems very sensible to me.

Without a clear exposition of what you are actually doing, I cannot
explain the subtleties of null content to you.

Regards

Ed Willink


On 10/05/2012 14:35, Christopher G. wrote:
> Edward Willink wrote on Wed, 09 May 2012 12:13
>> Hi
>>
>> o.ref.oclIsUndefined() is a shortform for
>> o.ref->collect(oclIsUndefined()) so you get a (empty) collection of
>> the element returns.
>
>
> Okay, this makes sense.
>
>
> Edward Willink wrote on Wed, 09 May 2012 12:13
>> You don't say how you create your intermediate class object so a
>> response is possible. I suspect you are using the implicit ->
>> conversion. o.ref->size() = 1 seems very sensible to me.
>
>
> Size 1 is sensible, why? The object o is created via 'object' keyword.
> Without explicit initialization of the ref feature, the null check
> returns false. Obviously, the feature has been initialized
> automatically. For the automatic initialization I would assume an
> empty collection. Instead, there seems to be an instance of OclVoid
> inside the collection, which implies the size 1.
>
> The actual problem is that the OclVoid instance remains during
> execution, i.e. when first adding to that collection, the size is 2
> and so on...
>
>
>
>
Re: [QVTO] Default initialization of * features [message #871736 is a reply to message #871357] Mon, 14 May 2012 15:07 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher Gerking
Messages: 39
Registered: April 2011
Member
This is the definition of my intermediate class:

intermediate class O {

ref : OrderedSet(O);
		
}


And this is how the instance is created. The assertion makes sense to me, but it fails due to an instance of OclVoid within the ref OrderedSet.

var o : O = object O {};

assert fatal (o.ref->size() = 0);
Re: [QVTO] Default initialization of * features [message #873203 is a reply to message #871736] Thu, 17 May 2012 13:12 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

I think you are being confused by the lack of unification and
consequent incompatibility between

UML's bounded collections
OCL's nested collections

The QVTo syntax supports UML's bounded collections:

ref : O ordered

Oops: this is not in the QVTo grammar, just the examples and where is
'unique' ?

So when you used

ref : OrderedSet(O)

you were specifying a singleton element of collection type; well worth a
warning message.

Unification of these syntaxes is one of my current OCL activities.

Regards

Ed Willink


On 14/05/2012 20:07, Christopher G. wrote:
> This is the definition of my intermediate class:
>
>
> intermediate class O {
>
> ref : OrderedSet(O);
>
> }
>
>
> And this is how the instance is created. The assertion makes sense to
> me, but it fails due to an instance of OclVoid within the ref OrderedSet.
>
>
> var o : O = object O {};
>
> assert fatal (o.ref->size() = 0);
>
Re: [QVTO] Default initialization of * features [message #874664 is a reply to message #873203] Mon, 21 May 2012 06:34 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher Gerking
Messages: 39
Registered: April 2011
Member
Hi,

thanks for your response.

So using UML bounded collections is a proper workaround.
However, why is it a problem if I specify a singleton element of collection type?

Am I wrong if I still consider the contained instance of OclVoid as a bug?
Re: [QVTO] Default initialization of * features [message #874673 is a reply to message #874664] Mon, 21 May 2012 06:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
On 21/05/2012 11:34, Christopher G. wrote:
> Hi,
>
> thanks for your response.
>
> So using UML bounded collections is a proper workaround.

It's not a workaround. It's just correct.
> However, why is it a problem if I specify a singleton element of
> collection type?
> Am I wrong if I still consider the contained instance of OclVoid as a
> bug?
When you use nonsensical statements, you can only complain about missing
error messages.

Regards

Ed Willink
Re: [QVTO] Default initialization of * features [message #874729 is a reply to message #874673] Mon, 21 May 2012 08:56 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher Gerking
Messages: 39
Registered: April 2011
Member
Ok, I didn't understand it was actually nonsensical, sorry. And I still do not understand the relation to UML, but it's ok.

After changing to UML bounded collections, the += operator does not work anymore.
How can I add to such a collection?
Re: [QVTO] Default initialization of * features [message #874748 is a reply to message #874729] Mon, 21 May 2012 09:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

I'm not telepathic. It's not sensible to expect me to apply the same
edits as you and then diagnose your problems.

Also "does not work" is notoriously uninformative.

Regards

Ed Willink


On 21/05/2012 13:57, Christopher G. wrote:
> Ok, I didn't understand it was actually nonsensical, sorry. And I
> still do not understand the relation to UML, but it's ok.
>
> After changing to UML bounded collections, the += operator does not
> work anymore.
> How can I add to such a collection?
Re: [QVTO] Default initialization of * features [message #874819 is a reply to message #874748] Mon, 21 May 2012 11:46 Go to previous messageGo to next message
Christopher Gerking is currently offline Christopher Gerking
Messages: 39
Registered: April 2011
Member
Sorry, this is how I changed my intermediate class definition:

intermediate class O {
		
ref : O ordered;
		
}


The += code below produces the compilation error "Property 'ref' must have collection type".

object O {

ref += ...
						
}
Re: [QVTO] Default initialization of * features [message #874826 is a reply to message #874819] Mon, 21 May 2012 11:57 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

Sorry, but I think it's about time you started doing some work for
yourself; I have my own work to do.

If you look at the QVT specification you will find at least 20 examples
of the solution to your problem and no indication that what you have
done is sensible.

Regards

Ed Willink


On 21/05/2012 16:46, Christopher G. wrote:
> Sorry, this is how I changed my intermediate class definition:
>
>
> intermediate class O {
>
> ref : O ordered;
>
> }
>
>
> The += code below produces the compilation error "Property 'ref' must
> have collection type".
>
>
> object O {
>
> ref += ...
>
> }
>
Previous Topic:Proper use of libraries
Next Topic:Transformations between enums in QVTo
Goto Forum:
  


Current Time: Fri Aug 29 22:31:05 EDT 2014

Powered by FUDForum. Page generated in 0.03540 seconds