What does the marked line mean exactly? I mean, speaking of the name of
the edges reference, I consider it to be a set, but getCross() seems to
return just one element. Is that automatically converted to a set? I
had expect something like

And my other question is: What's the return value of called/lazy rules
if they have multiple target pattern elements? Only the first, or an
OrderedSet containing all of them? And do lazy rules allow for multiple
target pattern elements at all?

Does the second assignment insert the returned element into the refs
collection, or does a newly created collection with only the single
element replace the original value of the first assignment?

> Lazy rules allow to build multiple elements but be careful that only
> the first will be returned.

Thanks.

> If you need to catch more than one element, you should use a called
> rule instead of a lazy rule because in a called rule you explicitly
> specify the returned elements ex :
>
> rule getCross(i: ecore!EObject) {
> to
> rel: metamodel!Relationship (
> ),
> rel2 : metamodel!Relationship(
> )
> do{
> -- here you specifiy the element(s) returned by the called rule
> Sequence{rel,rel2};
> }
> }

Ah, that's kinda nice. But the User Guide states that inside the
imperative code section only a sequence of statements is allowed. So is
the principle that a called rule rule usually returns the value of the
first target pattern variable, unless the imperative code section's last
statement is an expression. In that case, the value of the expression
is returned.

Does the second assignment insert the returned element into the refs
collection, or does a newly created collection with only the single
element replace the original value of the first assignment?

No, the element is added at the end of the collection so in the end the collection refs will contain the result of the getSomeRefs followed by the result of the getOneRef.

Quote:

Ah, that's kinda nice. But the User Guide states that inside the
imperative code section only a sequence of statements is allowed. So is
the principle that a called rule rule usually returns the value of the
first target pattern variable, unless the imperative code section's last
statement is an expression. In that case, the value of the expression
is returned.

In a called rule you ALWAYS have to specify what the rule returns even if it's only one element (unless it changed in the last ATL version).

> Quote:
>> to foo : MM!Thing
>> do {
>> foo.refs <- thisModule.getSomeRefs(foo);
>> foo.refs <- thisModule.getOneRef(foo);
>> }
>>
>> Does the second assignment insert the returned element into the refs
>> collection, or does a newly created collection with only the single
>> element replace the original value of the first assignment?
>
> No, the element is added at the end of the collection so in the end
> the collection refs will contain the result of the getSomeRefs
> followed by the result of the getOneRef.

Oh, that's great.

> Quote:
>> Ah, that's kinda nice. But the User Guide states that inside the
>> imperative code section only a sequence of statements is allowed. So is
>> the principle that a called rule rule usually returns the value of the
>> first target pattern variable, unless the imperative code section's last
>> statement is an expression. In that case, the value of the expression
>> is returned.
>
> In a called rule you ALWAYS have to specify what the rule returns even
> if it's only one element (unless it changed in the last ATL version).

> If you use a given called rule in an expression, then it must return a
> value, and this value must be returned from the do block, which is
> non-optional *in this specific case*.
>
> However, called rule do not need to return values: they may be called
> as statements from other do blocks. Therefore, the do block is indeed
> optional.