[ATL] passing parameters to transformations [message #34810] |
Fri, 27 April 2007 15:59 |
Eclipse User |
|
|
|
Originally posted by: r.c.ladan.tue.nl
Hi,
is it possible to pass a parameter to a transformation? I know that
only called rules can take parameters, but I want to do something like:
rule faster_cpu { -- pass parameter (f : Double)
from
c : meta!cpu
to
c1 : meta!cpu(
frequency <- c.frequency * f
)
}
Can I pass f from e.g. a dialog box ? Adding f to the from section
(using atl2006) gives an interpreter error/stack trace.
Thanks,
Rene
|
|
|
Re: [ATL] passing parameters to transformations [message #34947 is a reply to message #34810] |
Fri, 27 April 2007 23:45 |
Frédéric Jouault Messages: 572 Registered: July 2009 |
Senior Member |
|
|
Hello,
You can pass additional parameters to a transformation as a model. See:
http://wiki.eclipse.org/index.php/ATL_Howtos#How_do_I_use_ex tern_parameters_in_ATL_transformations.3F
However, you apparently do not want to pass parameters to a
transformation but to a rule. This is not possible with matched (i.e.,
declarative) rules, only with called (i.e., imperative) rules.
That said, you usually do not need to pass parameters to matched rules
because you can "decorate" the source model with helpers.
For instance, you could define the following attribute helper:
helper context meta!cpu def: f : Real =
<some expression that may navigate the model recursively (e.g., using
refImmediateComposite()>;
This way, you separate the computation of the "parameter" from the
execution flow of declarative rules, on which you do not have explicit
control (this is partly why it is called declarative: you do not have to
explicitly specify everything).
Regards,
Frédéric Jouault
Rene Ladan wrote:
> Hi,
>
> is it possible to pass a parameter to a transformation? I know that
> only called rules can take parameters, but I want to do something like:
>
> rule faster_cpu { -- pass parameter (f : Double)
> from
> c : meta!cpu
> to
> c1 : meta!cpu(
> frequency <- c.frequency * f
> )
> }
>
> Can I pass f from e.g. a dialog box ? Adding f to the from section
> (using atl2006) gives an interpreter error/stack trace.
>
> Thanks,
> Rene
|
|
|
Re: [ATL] passing parameters to transformations [message #35531 is a reply to message #34947] |
Tue, 01 May 2007 08:11 |
Eclipse User |
|
|
|
Originally posted by: r.c.ladan.tue.nl
Frédéric Jouault wrote:
> Hello,
>
> You can pass additional parameters to a transformation as a model. See:
> http://wiki.eclipse.org/index.php/ATL_Howtos#How_do_I_use_ex tern_parameters_in_ATL_transformations.3F
>
Got it running. Thanks for the pointer.
>
> However, you apparently do not want to pass parameters to a
> transformation but to a rule. This is not possible with matched (i.e.,
> declarative) rules, only with called (i.e., imperative) rules.
>
Hmm, I guess the example was too small.
Regards,
Rene
> Rene Ladan wrote:
>> Hi,
>>
>> is it possible to pass a parameter to a transformation? I know that
>> only called rules can take parameters, but I want to do something like:
>>
>> rule faster_cpu { -- pass parameter (f : Double)
>> from
>> c : meta!cpu
>> to
>> c1 : meta!cpu(
>> frequency <- c.frequency * f
>> )
>> }
>>
>> Can I pass f from e.g. a dialog box ? Adding f to the from section
>> (using atl2006) gives an interpreter error/stack trace.
>>
>> Thanks,
>> Rene
|
|
|
Powered by
FUDForum. Page generated in 0.02950 seconds