Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Is there a better [let] construct for multiple variable context(Is there a better [let] construct for multiple variable context)
Is there a better [let] construct for multiple variable context [message #1733446] Fri, 27 May 2016 14:46 Go to next message
Shimon Zadok is currently offline Shimon ZadokFriend
Messages: 24
Registered: May 2016
Junior Member
I would like to store the result in a variable after a log sequence.
The let construct make is easier.
Though using it multiple times is not that pretty as it looks like nesting (while it is for the sake of scoping).

[let aPrimitiveType : PrimitiveType = aClass.clientDependency->asSequence()->first().supplier->filter(PrimitiveType)->asSequence()->first() ]
[let aStereoType : Stereotype = aPrimitiveType.getAppliedStereotypes()->asSequence()->first() ]

PrimitiveType: [aPrimitiveType.name /] StereoType: [aStereoType.name /]

[/let][/let]


Am I missing a better way? even for the retrieval of the first element?

[Updated on: Sat, 28 May 2016 08:37]

Report message to a moderator

Re: Is there a better [let] construct for multiple variable context [message #1733764 is a reply to message #1733446] Tue, 31 May 2016 13:58 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
hi,

Pay attention that the "let" of Acceleo, as specified by the MOF Model-to-text Transformation Language, is the same as an "if <something>.oclIsKindOf" :

[let aPrimitiveType : PrimitiveType = xxx]

This will only enter the "let" body if "xxx" is of kind "PrimitiveType". Otherwise it'll just ignore the let.

That being said, there is no other way to keep variables around than the let except for the initialization of a block, but you wouldn't have access to every variable there, so that is your go-to method in such cases.

Laurent Goubet
Obeo
Previous Topic:[solved] Where to find [macro] usage (and an example)?
Next Topic:Acceleo : How do I compare the value of the current and the previous iteration in a for loop
Goto Forum:
  


Current Time: Mon Sep 23 08:12:27 GMT 2024

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

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

Back to the top