Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] map versus xmap
[QVTO] map versus xmap [message #643285] Mon, 06 December 2010 06:49 Go to next message
Tassilo Horn is currently offline Tassilo Horn
Messages: 93
Registered: July 2009
Member
Hi all,

I'm reading the QVT 1.0 spec, and now it managed to confuse me. In
Section 8.2.1.21 it says:

A mapping call expression represents the invocation of a mapping
operation. A mapping operation can be invoked either in strict mode
or in standard mode, depending on the value of the isStrict Boolean
property. In strict mode the when clause is evaluated as a
pre-condition. In contrast, when the mapping is invoked in standard
mode, the execution of the mapping body is skipped and the null
value is returned to the caller.

The map keyword is defined to have non-strict semantics, the xmap
keyword is defined to have strict semantics.

Unfortunately, that doesn't match with my experiences. In fact, till
now I did not know about xmap at all and use map throughout my QVTO
transformations. And concluding from the fact that my transformations
produce the expected output model anyway, the skipping of the called
mapping body and returning null seems not to be true.

Is that a divergence between implementation and spec?

And what's the intention in non-strict mapping calls as defined by the
spec altogether?

BTW: Is there a table that shows divergences between QVT spec and the
implementation?

Thanks a lot in advance,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
Re: [QVTO] map versus xmap [message #643314 is a reply to message #643285] Mon, 06 December 2010 08:22 Go to previous messageGo to next message
Dennis Hendriks is currently offline Dennis Hendriks
Messages: 63
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Hi Tassilo,

> The map keyword is defined to have non-strict semantics, the xmap
> keyword is defined to have strict semantics.

Yes. The implementation however implements both as map. See bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=301134


> And concluding from the fact that my transformations
> produce the expected output model anyway, the skipping of the called
> mapping body and returning null seems not to be true.

Maybe:

- you didn't even use pre-conditions?

- the condition always holds?

- you used a disjunct or something else that continues with the next
alternative if one doesn't match? Note that in such a case, if xmap is
used on a disjuncts mapping, I think it should try the alternatives in
order, and if none of them matches, it should give an error, if it
weren't for the bug mentioned above.

- maybe the condition is indeed sometimes not matched, and the mapping
does result in 'null', but you didn't notice this? Note that for
optional features, setting it to 'null' is like not setting it, and it
may still produce a valid instance of the metamodel. Similarly, for
multi-valued features, if one of the elements is mapped to 'null', it is
simply not included in the output (assuming the target feature is also
multi-valued).

Best regards,
Dennis




Tassilo Horn wrote:
> Hi all,
>
> I'm reading the QVT 1.0 spec, and now it managed to confuse me. In
> Section 8.2.1.21 it says:
>
> A mapping call expression represents the invocation of a mapping
> operation. A mapping operation can be invoked either in strict mode
> or in standard mode, depending on the value of the isStrict Boolean
> property. In strict mode the when clause is evaluated as a
> pre-condition. In contrast, when the mapping is invoked in standard
> mode, the execution of the mapping body is skipped and the null
> value is returned to the caller.
>
> The map keyword is defined to have non-strict semantics, the xmap
> keyword is defined to have strict semantics.
>
> Unfortunately, that doesn't match with my experiences. In fact, till
> now I did not know about xmap at all and use map throughout my QVTO
> transformations. And concluding from the fact that my transformations
> produce the expected output model anyway, the skipping of the called
> mapping body and returning null seems not to be true.
>
> Is that a divergence between implementation and spec?
>
> And what's the intention in non-strict mapping calls as defined by the
> spec altogether?
>
> BTW: Is there a table that shows divergences between QVT spec and the
> implementation?
>
> Thanks a lot in advance,
> Tassilo
Re: [QVTO] map versus xmap [message #643331 is a reply to message #643314] Mon, 06 December 2010 09:05 Go to previous messageGo to next message
Tassilo Horn is currently offline Tassilo Horn
Messages: 93
Registered: July 2009
Member
Dennis Hendriks <d.hendriks@tue.nl> writes:

Hi Dennis,

>> The map keyword is defined to have non-strict semantics, the xmap
>> keyword is defined to have strict semantics.
>
> Yes. The implementation however implements both as map. See bug:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=301134

Thanks for the pointer. Reading the bug report, it seems, that my
confusion comes from the imprecise formulation of the spec:

In strict mode the when clause is evaluated as a pre-condition. In
contrast, when the mapping is invoked in standard mode, the
execution of the mapping body is skipped and the null value is
returned to the caller.

So here is the formulation again with some additions made by me to make
it clear:

In strict mode the when clause is evaluated as a pre-condition [and
thus an exception is thrown if it does not hold. In case of a list
of disjunctive mappings, the exception is thrown when no
precondition holds]. In contrast, when the mapping is invoked in
standard mode [and the when clause does not hold], the execution of
the mapping body is skipped and the null value is returned to the
caller.

Is that the correct interpretation?

>> And concluding from the fact that my transformations produce the
>> expected output model anyway, the skipping of the called mapping body
>> and returning null seems not to be true.
>
> Maybe:
>
> - you didn't even use pre-conditions?

Well, I use when-clauses for dispatching what mapping is executed in
conjunction with mapping disjunction and inheritance.

> - you used a disjunct or something else that continues with the next
> alternative if one doesn't match? Note that in such a case, if xmap is
> used on a disjuncts mapping, I think it should try the alternatives in
> order, and if none of them matches, it should give an error, if it
> weren't for the bug mentioned above.

Ah, I see. That makes a lot of sense. :-)

Bye,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
Re: [QVTO] map versus xmap [message #643346 is a reply to message #643331] Mon, 06 December 2010 10:15 Go to previous messageGo to next message
Dennis Hendriks is currently offline Dennis Hendriks
Messages: 63
Registered: January 2010
Location: Eindhoven, The Netherland...
Member
Hi Tassilo,

> Is that the correct interpretation?

Yes, I think so. But I'm not an expert...


> Well, I use when-clauses for dispatching what mapping is executed in
> conjunction with mapping disjunction and inheritance.

To work around this, maybe you could make a new mapping, that checks the
conditions and does manual dispatching to the correct mapping. If none
of the conditions holds, you manually do an assert fatal to stop execution.

Obviously, fixing the implementation (assuming it is broken), and not
working around it, is preferred.


Best regards,
Dennis



Tassilo Horn wrote:
> Dennis Hendriks <d.hendriks@tue.nl> writes:
>
> Hi Dennis,
>
>>> The map keyword is defined to have non-strict semantics, the xmap
>>> keyword is defined to have strict semantics.
>> Yes. The implementation however implements both as map. See bug:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=301134
>
> Thanks for the pointer. Reading the bug report, it seems, that my
> confusion comes from the imprecise formulation of the spec:
>
> In strict mode the when clause is evaluated as a pre-condition. In
> contrast, when the mapping is invoked in standard mode, the
> execution of the mapping body is skipped and the null value is
> returned to the caller.
>
> So here is the formulation again with some additions made by me to make
> it clear:
>
> In strict mode the when clause is evaluated as a pre-condition [and
> thus an exception is thrown if it does not hold. In case of a list
> of disjunctive mappings, the exception is thrown when no
> precondition holds]. In contrast, when the mapping is invoked in
> standard mode [and the when clause does not hold], the execution of
> the mapping body is skipped and the null value is returned to the
> caller.
>
> Is that the correct interpretation?
>
>>> And concluding from the fact that my transformations produce the
>>> expected output model anyway, the skipping of the called mapping body
>>> and returning null seems not to be true.
>> Maybe:
>>
>> - you didn't even use pre-conditions?
>
> Well, I use when-clauses for dispatching what mapping is executed in
> conjunction with mapping disjunction and inheritance.
>
>> - you used a disjunct or something else that continues with the next
>> alternative if one doesn't match? Note that in such a case, if xmap is
>> used on a disjuncts mapping, I think it should try the alternatives in
>> order, and if none of them matches, it should give an error, if it
>> weren't for the bug mentioned above.
>
> Ah, I see. That makes a lot of sense. :-)
>
> Bye,
> Tassilo
Re: [QVTO] map versus xmap [message #643350 is a reply to message #643346] Mon, 06 December 2010 10:34 Go to previous message
Tassilo Horn is currently offline Tassilo Horn
Messages: 93
Registered: July 2009
Member
Dennis Hendriks <d.hendriks@tue.nl> writes:

Hi Dennis,

>> Is that the correct interpretation?
>
> Yes, I think so. But I'm not an expert...

Thanks.

>> Well, I use when-clauses for dispatching what mapping is executed in
>> conjunction with mapping disjunction and inheritance.
>
> To work around this, maybe you could make a new mapping, that checks
> the conditions and does manual dispatching to the correct mapping. If
> none of the conditions holds, you manually do an assert fatal to stop
> execution.

Well, looking at my transformations it seems to me that I never use a
mapping call that is allowed to return null, so using xmap would be the
right thing to use. But since I'm only learning QVTO and thus my models
are relatively small, I prefer a manual verification of the output model
over making the code worse readable with such workarounds. :-)

Anyway, thanks again for your help!
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
Previous Topic:[ATL] How does ATL accept instances of two related models
Next Topic:[ATL] Problems installing ATL in Papyrus
Goto Forum:
  


Current Time: Fri Aug 22 09:51:39 EDT 2014

Powered by FUDForum. Page generated in 0.01702 seconds