[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [QVTO] How to cast and do a return?

Hi Gilbert,

You do not have to return a result value explicitly from mappings.
The result object will be created for you implicitly, unless
you assign it explicitly via the  predefined 'result' variable,
which actually always represents your return value.

If a mapping that defines a return type does not use explicit
return statement, it still implicitly returns the value of the 'result'
variable to the caller.

As I have mentioned, in your case there is no return type declared,
which is internally mapped to OclVoid type and must always result
in 'null' value. Basically, it would be used purely for controlling
the execution flow.

If you need to create, modify your models use mapping operation.
It gives you some benefits like implicit instantiation, traceability,
mapping reuse mechanism.

As for refactoring, hard to guess what you intend to do. Just try out
and come here with a particular problem to solve.

Perhaps, you might want to look for this semantics at http://www.eclipse.org/m2m/qvto/doc/M2M-QVTO.pdf,
I believe it should be easier to understand then the OMG spec.


Regards,
/Radek


On Thu, 10 Sep 2009 09:36:42 +0200, Gilbert Mirenque <formatzeh@xxxxxx> wrote:


Hi Radek,
Ok thank you. Yes I can restructure the mapping. But you mentioned that
mappings normally should return something. Maybe it would be better in
my case that I refactor my mapping into a helper? I fear that I can read
about the exact intention of mapping and helper in the QVT spec from the
OMG :(

best regards,
Gilbert

radek dvorak wrote:
Hi Gilbert,

Using 'return' from mapping operations is limitation of the current QVTO
release.
The reason is that a mapping typically has a return type and consequently
a predefined 'result' variable, which receives its final value within or
just
in the end of 'init' section.
It might be a bit confusing if a mapping returned (via explicit return
expression)
a value different from the one already recorded in traces.


The OMG spec is not clear about this situation so we imposed this
limitation,
thinking it can always be solved in an alternative way.

In your mapping we actually could allow explicit return as there is no
result
variable involved.

However, for now, I assume you can just restructure your mapping to
avoid the need for
return expression.

We also have to rethink some other cases to make things more flexible.

Regards,
/Radek