Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] - Create Integer set and add a new integer.
icon5.gif  [ATL] - Create Integer set and add a new integer. [message #762559] Thu, 08 December 2011 09:55 Go to next message
Charles anon is currently offline Charles anonFriend
Messages: 13
Registered: December 2011
Junior Member
I'm hoping someone may shed a bit of light for me, I can't seem to get this to work.

I set up the variable as:
helper def: int_set: Set(Integer) = Set{8, 15, 6, 3, 19};

then in a do statement I have tried various strategies of adding a new variable without success.

E.g.1 : thisModule.int_set -> insertAt(0,10);

The error : org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: Set {19, 3, 6, 8, 15}.insertAt(java.lang.Integer,java.lang.Integer)


E.g.2 : thisModule.int_set <- thisModule.int_set -> insertAt(0,10);

E.g.3 : thisModule.int_set -> append(10);


Just for reference, the variable seems ok since it prints fine with the following:
('thisModule.int_set: ' + thisModule.int_set.toString()).println();

Regards.
Re: [ATL] - Create Integer set and add a new integer. [message #762586 is a reply to message #762559] Thu, 08 December 2011 10:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You haven't grasped the benefit of the declarative approach that ATL
supports. You cannot modify anything, you just create it right first
time. No more opportunities for magic side effect mutation of working
values.

So OCL provides no modification operations for Collections, just
constructors of different collections.

e.g aSet->including(10) creates a new set with additional content.

[Whether a new set is actually created is dependent on the
implementation. Within the context of iteration loops, the new Eclipse
OCL implementation recognises stale collections and reuses them.]

Regards

Ed Willink




On 08/12/2011 09:55, spacetempest wrote:
> I'm hoping someone may shed a bit of light for me, I can't seem to get
> this to work.
>
> I set up the variable as:
> helper def: int_set: Set(Integer) = Set{8, 15, 6, 3, 19};
>
> then in a do statement I have tried various strategies of adding a new
> variable without success.
>
> E.g.1 : thisModule.int_set -> insertAt(0,10);
>
> The error : org.eclipse.m2m.atl.engine.emfvm.VMException: Operation
> not found: Set {19, 3, 6, 8,
> 15}.insertAt(java.lang.Integer,java.lang.Integer)
>
>
> E.g.2 : thisModule.int_set <- thisModule.int_set -> insertAt(0,10);
>
> E.g.3 : thisModule.int_set -> append(10);
>
>
> Just for reference, the variable seems ok since it prints fine with
> the following: ('thisModule.int_set: ' +
> thisModule.int_set.toString()).println();
>
> Regards.
>
Re: [ATL] - Create Integer set and add a new integer. [message #762642 is a reply to message #762586] Thu, 08 December 2011 12:42 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
In ATL you could try
thisModule.int_set <- thisModule.int_set->append(10);
Re: [ATL] - Create Integer set and add a new integer. [message #762647 is a reply to message #762586] Thu, 08 December 2011 12:52 Go to previous messageGo to next message
Charles anon is currently offline Charles anonFriend
Messages: 13
Registered: December 2011
Junior Member
Yes, unfortunately haven't yet grasped the declarative approach yet. I'm trying to transform a hierarchy description from one model to a hierarchy into another. For the life of me I can't figure out how to set up the associations between the different levels. I shall post more about this on a new thread. The reason I wished to have a set was that I could have a rule to implement the lowest of children (using a set to record their ids) and then have a rule that progressively implemented the parents.

If there is a better method to reconstruct a hierarchy, I would of course like to hear it (in the other thread I am about to create), but when the ATL documentation says:

"An example of the insertion of the element 15 at the second place is:
Sequence{12, 13, 12}->insertAt(2,15)
which results in:
Sequence{5, 10, 15, 20}"

which looks like a modification operation to me...


@Sylvain: I tried your suggestion
thisModule.int_set <- thisModule.int_set->append(10);
and get the error:
...VMException: Operation not found: Set {19, 3, 6, 8, 15}.append(java.lang.Integer)

Re: [ATL] - Create Integer set and add a new integer. [message #762659 is a reply to message #762647] Thu, 08 December 2011 13:10 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
try including then
Re: [ATL] - Create Integer set and add a new integer. [message #762827 is a reply to message #762647] Thu, 08 December 2011 17:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

OCL does define insertAt on Sequence and OrderedSet, but they are
constructors of new collections not mutators.

Sequence{12, 13, 12}->insertAt(2,15)
absolutely should not result in
Sequence{5, 10, 15, 20}

quite apart from the wrong values, the index is wrong too. OCL is a
specification language so indexes count from 1.

Result should be Sequence{12,15,13,12}

Regards

Ed Willink

On 08/12/2011 12:52, spacetempest wrote:
> Yes, unfortunately haven't yet grasped the declarative approach yet.
> I'm trying to transform a hierarchy description from one model to a
> hierarchy into another. For the life of me I can't figure out how to
> set up the associations between the different levels. I shall post
> more about this on a new thread. The reason I wished to have a set
> was that I could have a rule to implement the lowest of children
> (using a set to record their ids) and then have a rule that
> progressively implemented the parents.
>
> If there is a better method to reconstruct a hierarchy, I would of
> course like to hear it (in the other thread I am about to create), but
> when the ATL documentation says:
>
> "An example of the insertion of the element 15 at the second place is:
> Sequence{12, 13, 12}->insertAt(2,15)
> which results in:
> Sequence{5, 10, 15, 20}"
>
> which looks like a modification operation to me...
>
>
> @Sylvain: I tried your suggestion thisModule.int_set <-
> thisModule.int_set->append(10); and get the error:
> ..VMException: Operation not found: Set {19, 3, 6, 8,
> 15}.append(java.lang.Integer)
>
>
Re: [ATL] - Create Integer set and add a new integer. [message #763404 is a reply to message #762827] Fri, 09 December 2011 17:49 Go to previous messageGo to next message
Charles anon is currently offline Charles anonFriend
Messages: 13
Registered: December 2011
Junior Member
Two replies of mine have disappeared while using these forums. Sad

Thanks for taking the time to reply Ed. The example I mentioned (copied from ATL_VMSpecification 2005) was merely to point out my confusion about you saying modification was not possible, and a function existing in the documentation that suggested the opposite. I did not check the numbers assuming they would be correct, a rather amusing typo from the documentation.

I'm still stuck with the original problem that insertAt/append do not function. Do I need to create a new set additional to int_set (the one I proposed in my first post) in order to do this.


Re: [ATL] - Create Integer set and add a new integer. [message #763454 is a reply to message #763404] Fri, 09 December 2011 20:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

On 09/12/2011 17:49, spacetempest wrote:
> Two replies of mine have disappeared while using these forums. :(
It's very irritating. I use only the newsgroups.
> Thanks for taking the time to reply Ed. The example I mentioned
> (copied from ATL_VMSpecification 2005) was merely to point out my
> confusion about you saying modification was not possible, and a
> function existing in the documentation that suggested the opposite. I
> did not check the numbers assuming they would be correct, a rather
> amusing typo from the documentation.
>
> I'm still stuck with the original problem that insertAt/append do not
> function. Do I need to create a new set additional to int_set (the
> one I proposed in my first post) in order to do this.
>
The success of ATL arises from its providing useful functionality while
QVT was (and arguably still is) gestating. Unfortunately there are a
number of aspects that are a bit pragmatic. Currently it uses its own
rather vintage and not entirely accurate form of OCL.

In OCL, insertAt is only applicable to Sequence and OrderedSet.

OrderedSet was a more recent addition than Set, Sequence and Bag and
realised by some slightly simplistic cut and paste in the OCL specification.

It may be that ATL's OCL predates a coherent OrderedSet.

But Sequence::insertAt() really should work.

Regards

Ed Willink
Re: [ATL] - Create Integer set and add a new integer. [message #763460 is a reply to message #763454] Fri, 09 December 2011 20:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
On 09/12/2011 20:00, Ed Willink wrote:
>
> On 09/12/2011 17:49, spacetempest wrote:
>> Two replies of mine have disappeared while using these forums. :(
> It's very irritating. I use only the newsgroups.
Just been looking for Bugzillas on these problems. Seems a syncer went
down two weeks ago,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364264, but the Bugzilla
suggests it should have caught up.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=348464 suggests that all
Eclipse committers use only the newsgroups.

You might care to raise a Bugzilla to identify your lost messages.

Regards

Ed Willink
Re: [ATL] - Create Integer set and add a new integer. [message #765524 is a reply to message #763454] Wed, 14 December 2011 08:43 Go to previous message
Charles anon is currently offline Charles anonFriend
Messages: 13
Registered: December 2011
Junior Member
Thanks! That works a treat. (using Sequence instead of Set)

Looking at the definition of these two it is clearer why the example from the documentation didn't work since 'Set' is both unordered and cannot accept a duplicate entry so a loop trying to append the same number will not work and obviously insertAt will not work.

[Updated on: Wed, 14 December 2011 08:49]

Report message to a moderator

Previous Topic:Re: [M2M] model2xhtml QVT problem
Next Topic:Select a Component from bag
Goto Forum:
  


Current Time: Thu Mar 28 22:00:56 GMT 2024

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

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

Back to the top