[ATL] Unique Called Rules [message #73101] |
Tue, 22 January 2008 23:42 |
Eclipse User |
|
|
|
Originally posted by: irbull.cs.uvic.ca
When rules elements in an input model are matched in ATL, they are only
matched once, but when a called rule is called more than once, it can
generate more than one result.
Is there a way to use a called (lazy) rule such that, if the rule has
already been called on a given input, return the previously created
object, otherwise create a new one?
The reason I ask is because I need to write a rule that matches Strings,
and for each unique string, create a target element.
cheers,
ian
|
|
|
Re: [ATL] Unique Called Rules [message #73443 is a reply to message #73101] |
Sat, 26 January 2008 22:17 |
Juancho Messages: 17 Registered: July 2009 |
Junior Member |
|
|
Hi Ian,
AFAIK, you can use an UNIQUE lazy rule to that end.
For instance, given the following rule:
unique lazy rule A2X {
from
a : SourceMM!A
to
x : TargetMM!X
}
It will create a new X object each time you invoke it on a "new" A
object whilst if you invoke it with an already used A object, it will
return the previously created X object.
Hope this helps.
Juancho
Ian Bull escribió:
> When rules elements in an input model are matched in ATL, they are only
> matched once, but when a called rule is called more than once, it can
> generate more than one result.
>
> Is there a way to use a called (lazy) rule such that, if the rule has
> already been called on a given input, return the previously created
> object, otherwise create a new one?
>
> The reason I ask is because I need to write a rule that matches Strings,
> and for each unique string, create a target element.
>
> cheers,
> ian
|
|
|
Re: [ATL] Unique Called Rules [message #73460 is a reply to message #73443] |
Sun, 27 January 2008 05:25 |
Eclipse User |
|
|
|
Originally posted by: irbull.cs.uvic.ca
THANK-YOU SO MUCH!
I kept thinking that unique was associated with the calling of the
rule... This works perfectly!
Thanks again Juancho,
cheers,
ian
Juan M. Vara wrote:
> Hi Ian,
> AFAIK, you can use an UNIQUE lazy rule to that end.
> For instance, given the following rule:
>
> unique lazy rule A2X {
> from
> a : SourceMM!A
>
> to
> x : TargetMM!X
> }
>
> It will create a new X object each time you invoke it on a "new" A
> object whilst if you invoke it with an already used A object, it will
> return the previously created X object.
>
> Hope this helps.
> Juancho
>
>
> Ian Bull escribió:
>> When rules elements in an input model are matched in ATL, they are
>> only matched once, but when a called rule is called more than once, it
>> can generate more than one result.
>>
>> Is there a way to use a called (lazy) rule such that, if the rule has
>> already been called on a given input, return the previously created
>> object, otherwise create a new one?
>>
>> The reason I ask is because I need to write a rule that matches
>> Strings, and for each unique string, create a target element.
>>
>> cheers,
>> ian
>
|
|
|
Powered by
FUDForum. Page generated in 4.46660 seconds