Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ifExp in ATL textual syntax.
ifExp in ATL textual syntax. [message #1066975] Fri, 05 July 2013 06:12 Go to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 96
Registered: April 2013
Member
Hello, I saw in ATL grammar that ifExp is like that:
ifExp ::= 'if' oclExpression 'then' oclExpression 'else' oclExpression 'endif';

I would like to use something like 'if' oclExpression 'then' oclExpression 'endif';

Does anyone know how to manage that?

Althrough, is there something like breack(in "C" language) in ATL so it will help me to use ifExp like this:
ifExp ::= 'if' oclExpression 'then' oclExpression 'else' break 'endif';
Re: ifExp in ATL textual syntax. [message #1067076 is a reply to message #1066975] Fri, 05 July 2013 13:14 Go to previous messageGo to next message
Michal Kleczek is currently offline Michal Kleczek
Messages: 23
Registered: May 2013
Junior Member
Félix SILINOU KAMDEM wrote on Fri, 05 July 2013 06:12
Hello, I saw in ATL ifExp ::= 'if' oclExpression 'then' oclExpression 'else' break 'endif';


What would be the value of such an expression?
Comparing to C "if" in ATL is like "?:" operator - not "if" statement.
Remember that OCL is side-effect free so: what is your use case?

You can always write "if exp then exp else OclUndefined endif"

Thanks,
Michal
Re: ifExp in ATL textual syntax. [message #1067217 is a reply to message #1067076] Sun, 07 July 2013 14:15 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 96
Registered: April 2013
Member
I know that Michal,
But in my case I would like to do something like if something is true I will generate this, if not I do nothing.

Actually, I only want to do something if condition is true.
Re: ifExp in ATL textual syntax. [message #1067338 is a reply to message #1067217] Mon, 08 July 2013 06:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4032
Registered: July 2009
Senior Member
Hi

You are demanding that ATL behaves in a non-declarative way contrary to
its principles.

If you really want to do imperative programming, perhaps you should
consider an imperative technique such as Java, Xtend or QVTo.

ATL does have imperative capabilities, but they are discouraged, so
perhaps you overlooked them.

Regards

Ed Willink


On 07/07/2013 19:15, Félix SILINOU KAMDEM wrote:
> I know that Michal,
> But in my case I would like to do something like if something is true
> I will generate this, if not I do nothing.
>
> Actually, I only want to do something if condition is true.
Re: ifExp in ATL textual syntax. [message #1067359 is a reply to message #1067338] Mon, 08 July 2013 08:05 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 96
Registered: April 2013
Member
Thank.
It is possible to invoke java methods in ATL?

Can I ask you something @Ed? I want to know if there is an ATL methods we can use to break operation.
Re: ifExp in ATL textual syntax. [message #1067384 is a reply to message #1067359] Mon, 08 July 2013 09:22 Go to previous messageGo to next message
achraf lyazidi is currently offline achraf lyazidi
Messages: 10
Registered: May 2013
Junior Member
Hi, did you try something like that, just using the first expression and condition

if(aPerson.gender = #male) {
	thisModule.menNb <- thisModule.menNb + 1;
	thisModule.men->including(aPerson);
}
Re: ifExp in ATL textual syntax. [message #1067407 is a reply to message #1067384] Mon, 08 July 2013 10:30 Go to previous message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 96
Registered: April 2013
Member
Thank you everyone,
Like @Michal said before, "if" in ATL is like "?:" operator so I must an else_expression.

I just need to return in else case something which is not important.
Previous Topic:Full name reference - Classifiers seem not to be equal
Next Topic:Help for using properties through collection
Goto Forum:
  


Current Time: Wed Aug 27 11:02:15 EDT 2014

Powered by FUDForum. Page generated in 0.02850 seconds