[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmt] Re: [Epsilon] Problem with ECL

Hi Steve,

I can't reproduce this. For a Left model that contains only one Class A and a Right model that contains only one Class B I get the following result:

A <ClassA> B

which is correct. There is only one pair to be compared (why did you expect 4?), and when the ClassA rule is executed it returns true and so A and B are recorded as matching.

I suspect that both of your two models have 2 classes (A and B) each. That would explain the result: the 4 pairs first pass from rule ClassA which characterizes the A<->A and A<->B pairs as matching, and the B<->A and B<->B pairs as non-matching (your clause is l.name = 'A') and as a result, since at that point the engine has decided about all pairs, rule ClassB is not needed and thus is not executed.

Cheers,
Dimitrios

Steve Barrett wrote:
Hello,

I'm trying to use ECL to help with some model merging. Unfortunately I'm stuck.

My left model consits of a single class A, and the right a single class B. I'm using the follow code (class.ecl) to compare them and print out the match trace:


rule ClassA match l : Left!Class with r : Right!Class { compare : l.name = 'A' }

rule ClassB
 match l : Left!Class with r : Right!Class {
 compare : l.name = 'B' }

post {
 -- Print name of matching elements and of the rule that matched them.
 for (m in matchTrace.matches.select(m|m.isMatching)) {
   (m.left.name + ' <' + m.getRule().name + '> ' + m.right.name).println();
 }
}


I think that the four element pairings should cause each rule to fire once, so the output is a surprise to me:



A <ClassA> A A <ClassA> B


Where are the B to A, B to B pairings? Why did rule ClassA match A with B? And why does the second rule never fire?


I can't help put think that I'm missing something really basic here, but I have spent a bit of time trying to unravel this. Thanks for taking a look.

--Steve

P.S. I couldn't get "m.rules.first().name" as given in the Complete OO to DB comparison to work, which is why I'm using "m.getRule().name" Could this be a source of trouble?