Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Missing OCL language constructs
[ATL] Missing OCL language constructs [message #659280] Fri, 11 March 2011 19:39 Go to next message
Sebastian is currently offline SebastianFriend
Messages: 11
Registered: February 2011
Junior Member
Hi there,
I just noticed that in ATL it is not possible to use the "CollectionRangeCS" construct:

helper def : allDays : Sequence(Integer) = Sequence{1..31};


This is part of the OCL language (at least since 2.0 - I could not find older definition documents):
Ocl Specification from OMG
Because of the usefulness of a Sequence of consecutive Integers, there is a separate literal to create them. The elements
inside the curly brackets can be replaced by an interval specification, which consists of two expressions of type Integer,
Int-expr1 and Int-expr2, separated by '..'. This denotes all the Integers between the values of Int-expr1 and Int-expr2,
including the values of Int-expr1 and Int-expr2 themselves:
Sequence{ 1..(6 + 4) }
Sequence{ 1..10 }
-- are both identical to
Sequence{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }



Isn't ATL supporting all OCL definitions?

But much more important to me now: How to do something like Sequence{ 1..31 } ?
For static integers it is easy of course (1, 2, 3, ...) but I would like to use integer variables to create a sequence from n to m.

Any hints appreciated.
Regards,
Sebastian
Re: [ATL] Missing OCL language constructs [message #659492 is a reply to message #659280] Mon, 14 March 2011 09:41 Go to previous messageGo to next message
Ronan B is currently offline Ronan BFriend
Messages: 273
Registered: July 2009
Senior Member
Hi,
ATL doesn't implement the full OCL specification. The differences are often detailed in the ATL User Guide. The operation your looking to use isn't supported from I can see. You can of course replicate it using some loops (iterate and insertAt perhaps). See "Operations on collections" in the User Guide for a full list of supported operations.
Regard,
Ronan
Re: [ATL] Missing OCL language constructs [message #660398 is a reply to message #659492] Fri, 18 March 2011 10:18 Go to previous message
Sebastian is currently offline SebastianFriend
Messages: 11
Registered: February 2011
Junior Member
Thank you Ronan for pointing this out.

After spending too much time looking for a solution like the one you hinted (using iterate, and collection functions), I realized that the only possible solution to this is to use a recursive helper.

Using iterate and the collection functions without recursion is not going to help because all the functions on a collection of size n return 1 or n (or a fixed multiple of n) items - never an arbitrary k.

If someone else should stumble upon a similar problem:
helper def : createSequence(count : Integer, seq : Sequence(Integer)) : Sequence(Integer) =
	if count = 0 then seq else thisModule.createSequence(count-1, seq->append(count)) endif;


Regards,
Sebastian
Previous Topic:[ATL] Plugin-Development - ClassNotFoundException
Next Topic:[Xtend] Creation of associations (ClassCastException)
Goto Forum:
  


Current Time: Tue Sep 24 12:36:03 GMT 2024

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

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

Back to the top