Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » matched rule execution order
matched rule execution order [message #949821] Fri, 19 October 2012 10:32 Go to next message
Aran A is currently offline Aran AFriend
Messages: 30
Registered: January 2011
Member
Hello,

I'm reading the ATL documentation, and I have some doubts about "matched rule execution order" that I don't understand.

I have seen in the slides (slide #20) of "Model Refactoring and other Advanced ATL Techniques" (at EclipseCon09 Jouault&Piers) that:

** The order in which rules are matched and applied is not specified.
** The order in which bindings are applied is not specified.

What does "bindings" mean in this context? Are the statements in the "to" part of the rule? does it mean that the bindings of one rule are executed in any order (not-predefined) inside that rule, or that the order of several "to" (of several rules) are executed in a not-predefined order?

Moreover, they say "The execution of a binding cannot change the value of another", but I have seen rules like this:

rule ...
to t : Population!PopGroup (... persons <- [something])
do { ... t.persons <- t.persons.append(...) }

So, what does that sentence mean?

They say also "Target elements are not navigable", but I have a code like this:

rule ...
to t : Population!PopGroup (... persons <- [something])
do {
for (a in t.persons) {a.fullName.toString().println(); }
}

(it works)

So, I'm navigating in the target model, or not?

Finally, in the sentence "The order in which rules are matched and applied is not specified", does this "application" mean "the target element initialization"? I've done some tests with my silly code, and what I have seen is that the "target element initialization" is applied for the first rule in the transformation file, then for the second one, and so on. I've been lucky and is this by sheer chance? or perharps are there some details about execution order that I haven't understood?
My silly code is:
rule  r2
from  s: Families!Member
to t : Population!Person (... fullName <- s.name)

rule  r1
from  ...
to t : Population!PopGroup (... persons <- [something])
do { 
    for (a in t.persons) {a.fullName.toString().println(); }
}


With that code, the model is generated correctly and the println operation shows in the console the fullnames.
With the next code the model is generated again, the same as before. So, I understand that is this (the same model) what "the order is not important" mean. But the println operation shows "OclUndefined" values, I think it is because the "target element initialization" of r2 rule hasn't been done yet.
rule  r1
from  ...
to t : Population!PopGroup (... persons <- [something])
do { 
    for (a in t.persons) {a.fullName.toString().println(); }
}

rule  r2
from  s: Families!Member
to t : Population!Person (... fullName <- s.name)


So, I conclude that indeed there is an execution order between rules. Or am I completely lost?

Could somebody give some clues about this doubts? Thanks in advance.

Best regards,
Re: matched rule execution order [message #961788 is a reply to message #949821] Sun, 28 October 2012 15:53 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Op 19/10/12 12:32, Aran A schreef:
> Hello,
>
> I'm reading the ATL documentation, and I have some doubts about "matched rule
> execution order" that I don't understand.
> I have seen in the slides (slide #20) of "Model Refactoring and other
> Advanced ATL Techniques" (at EclipseCon09 Jouault&Piers) that:
>
> ** The order in which rules are matched and applied is not specified.
> ** The order in which bindings are applied is not specified.
>
> What does "bindings" mean in this context? Are the statements in the "to" part
> of the rule? does it mean that the bindings of one rule are executed in any

Bindings indeed refer to the "to" part, and more specifically to the "<-"
statements in the "to" part. Bindings are like regular assignments, except
that they also apply the implicit tracing mechanism. In the ATL documentation,
the term "assignment" is sometimes used to indicate bindings.

See also:
http://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Simple_target_pattern_element

> order (not-predefined) inside that rule, or that the order of several "to" (of
> several rules) are executed in a not-predefined order?

It means that we, the ATL developers, get to change the execution order when
we like to. For example, if we want to execute ATL rules in parallel, the rule
order is no longer guaranteed. Also, if we want to parallellise within a
single rule, the binding application order could change.

What it means for you, is that you should write your transformations in such a
way as to not depend on rule execution order:

(1) Always navigate the input model(s) only.
(2) Within the same rule, always refer to source elements only when defining
bindings.

>
> Moreover, they say "The execution of a binding cannot change the value of
> another", but I have seen rules like this:
>
> rule ...
> to t : Population!PopGroup (... persons <- [something])
> do { ... t.persons <- t.persons.append(...) }
>
> So, what does that sentence mean?
>
> They say also "Target elements are not navigable", but I have a code like this:
>
> rule ...
> to t : Population!PopGroup (... persons <- [something])
> do { for (a in t.persons) {a.fullName.toString().println(); }
> }
>
> (it works)
>
> So, I'm navigating in the target model, or not?

Yes, you are. Unfortunately, ATL does not detect all cases of target model
navigation, and allows you to do it. You may consider this a bug, and report
them as such.

The current ATL runtimes nicely execute everything top-to-bottom, so all of
this just works. Also, the fact that ATL work on EMF models - i.e. shared data
- means that parallellisation is not going to be for tomorrow... That said,
we're not going to support any code that depends on rule execution order.

Cheers,
Dennis

>
> Finally, in the sentence "The order in which rules are matched and applied is
> not specified", does this "application" mean "the target element
> initialization"? I've done some tests with my silly code, and what I have seen
> is that the "target element initialization" is applied for the first rule in
> the transformation file, then for the second one, and so on. I've been lucky
> and is this by sheer chance? or perharps are there some details about
> execution order that I haven't understood?
> My silly code is:
>
> rule r2
> from s: Families!Member
> to t : Population!Person (... fullName <- s.name)
>
> rule r1
> from ...
> to t : Population!PopGroup (... persons <- [something])
> do { for (a in t.persons) {a.fullName.toString().println(); }
> }
>
>
> With that code, the model is generated correctly and the println operation
> shows in the console the fullnames.
> With the next code the model is generated again, the same as before. So, I
> understand that is this (the same model) what "the order is not important"
> mean. But the println operation shows "OclUndefined" values, I think it is
> because the "target element initialization" of r2 rule hasn't been done yet.
>
> rule r1
> from ...
> to t : Population!PopGroup (... persons <- [something])
> do { for (a in t.persons) {a.fullName.toString().println(); }
> }
>
> rule r2
> from s: Families!Member
> to t : Population!Person (... fullName <- s.name)
>
>
> So, I conclude that indeed there is an execution order between rules. Or am I
> completely lost?
>
> Could somebody give some clues about this doubts? Thanks in advance.
>
> Best regards,
>


Cheers,
Dennis
Previous Topic:Error at execution: java.lang.NoClassDefFoundError
Next Topic:How to run ATL Plugin
Goto Forum:
  


Current Time: Fri Mar 29 05:04:32 GMT 2024

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

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

Back to the top