Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo] let =null
[acceleo] let =null [message #1756419] Thu, 16 March 2017 15:47 Go to next message
louis andia. is currently offline louis andia.Friend
Messages: 46
Registered: November 2016
Member
Hello,

I have a trouble with acceleo let.
When i have something like [let var: myObject = getMyObject('objectName')] and when "getMyObject" can return null, next instructions in my template are not executed and it's like an exit without any error.
I have to use OclAny to avoid that ( [let var: OclAny= getMyObject('objectName')] .
Is it the good behavior? Am I using acceleo the wrong way? It's look like dangerous to use something else than OclAny as type for a let, if your are not sure at 100% they is any possibility than your right part return null...
Re: [acceleo] let =null [message #1756427 is a reply to message #1756419] Thu, 16 March 2017 17:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

What you observe sounds familiar. https://bugs.eclipse.org/bugs/show_bug.cgi?id=320890

(The more recent Pivot-based OCL supports multiplicities more explicitly so you should be able to declare a let variable as [1] or [?].)

Today, it seems like OclAny gives you a workaround.

Regards

Ed Willink
Re: [acceleo] let =null [message #1756436 is a reply to message #1756427] Thu, 16 March 2017 20:27 Go to previous messageGo to next message
louis andia. is currently offline louis andia.Friend
Messages: 46
Registered: November 2016
Member
Thanks you for your answer.
Yes it's look like they is a similarity between these bugs.

OclAny works but it's not perfect. You have to use oclAsType every time you want to use it, and code is less readable.

If you have any documentation about Pivot-based OCL i take it, but i doubt acceleo let using it.

In fact, you have a warning when you try to affect null value directly, but using just a if statement and it disappear:
1) Warning "Possible incompatible type between 'String' and 'OclVoid'."
[let var: String = null]
[/let]
2) No warning
[let var: String = if true then null else '' endif]
[/let]

[Updated on: Thu, 16 March 2017 20:28]

Report message to a moderator

Re: [acceleo] let =null [message #1756437 is a reply to message #1756436] Thu, 16 March 2017 20:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

The Pivot-based OCL protypes solution to the many problems identified in http://www.omg.org/cgi-bin/doc?ad/14-03-05.pdf

One day it might happen. Then OCL-based specifications might follow suit.

MOFM2T 1.0 has an explicitly inconsistent let. Should it change?

MOFM2T has no active community maintaining the specification, so there is no progress/clarification/fixing wrt MOFM2T 1.0. Acceleo was revised to align with MOFM2T and makes a good attempt at implementing it, however there has been no feedback of Acceleo 'fixes' to create a MOFM2T 1.1.

IMHO M2T actually only requires two facilities not available in M2M languages: a) text output models, b) string template expressions. Better to upgrade OCL with b) and QVT with a). cf Xtend that supports M2T as part of a much more general facility.

Regards

Ed Willink
Re: [acceleo] let =null [message #1756439 is a reply to message #1756437] Thu, 16 March 2017 21:32 Go to previous messageGo to next message
louis andia. is currently offline louis andia.Friend
Messages: 46
Registered: November 2016
Member
Thanks you. I read the MOFM2T definition of let block and i understand the problem better.

I could use others blocks (elselet and else) but in my case it means code duplication instead of using an if block on a specific part.
It should be great to have a special value like "undefined" matching every type, or an option in let to authorize null value, or a finallet block to execute code regardless the value type of the let.
Re: [acceleo] let =null [message #1756453 is a reply to message #1756439] Fri, 17 March 2017 07:18 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

Yes, all suggestions worth considering.

You could raise an issue with the MOFM2T specification, but since no Revision Task Force has been chartered in the nine years since the standard was produced, it is clear that there is a very low level of interest in MOFM2T amongst OMG member companies or serious enthusiasts. Obeo, the developers of Acceleo, choose not to be an OMG member.

You could raise a Bugzilla against Acceleo, but as indicated in Bug 320890, MOFM2T compatibility inhibits most solutions.

Regards

Ed Willink
Previous Topic:Invalid Type (OCL Collection in Acceleo)
Next Topic:[Acceleo] NullPointerException when running standalone
Goto Forum:
  


Current Time: Wed Jan 17 07:42:10 GMT 2018

Powered by FUDForum. Page generated in 0.01842 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software