Skip to main content



      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 10:46 Go to next message
Eclipse UserFriend
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 04:37] by Moderator

Re: Is there a better [let] construct for multiple variable context [message #1733764 is a reply to message #1733446] Tue, 31 May 2016 09:58 Go to previous message
Eclipse UserFriend
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: Thu May 15 10:26:54 EDT 2025

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

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

Back to the top