[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,

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



On Wed, 09 Sep 2009 17:48:31 +0200, Gilbert Mirenque <formatzeh@xxxxxx> wrote:

Thanks Radek, the casting thing works. But the return thing doesn't. In
the following mapping

mapping CMM::ConceptualModel::addCommunicationModel(inout rootModel :
CMM::CompositionModel)
{
	if(self.container() = rootModel)
	then{
		if(rootModel.oclIsTypeOf(CompositeComponent))
		then{
			if(rootModel.oclAsType(CompositeComponent).referencedCompositionModel
= null)
			then{
				// here I want to just return or at least leave the outer if
				return;
			}endif;
		}endif;
		// some computations
	} else {
		log('container != rootModel (' + self.container().metaClassName() +
',' + rootModel.metaClassName() + ')', self) when true;
	}endif;
}

I just want to return or at least leave the outer if after the casting.
How do I achieve this? The editor gives me the following error:

Using ''return'' from mapping operation is not yet supported

best regards,
Gilbert