Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Syntax clarification.
Syntax clarification. [message #787662] Tue, 31 January 2012 21:07 Go to next message
Renato Perini is currently offline Renato PeriniFriend
Messages: 6
Registered: January 2012
Junior Member
Hello.
I would like some clarification about "method" invocations in acceleo.
Sometimes I see syntaxes like this:

1) mod.eAllContents(Class)

sometimes, instead, I see a syntax like this:


var.memberEnd->at(2)

What's the difference between 1) and 2)?
1) call the method "eAllContents", while 2) call the at() method, but the first is called with a point operator, the second is called with a -> operator. What are the differences?

Thank you.
Re: Syntax clarification. [message #787696 is a reply to message #787662] Tue, 31 January 2012 21:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

. is an operation that is executed on a single element and if you call it on a list it is executed on every element and the result is collected (aka map in Xtend2 or collect in Xpand)
-> is exexuted on the a list itself and not its elements

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Syntax clarification. [message #788055 is a reply to message #787696] Wed, 01 February 2012 09:44 Go to previous messageGo to next message
Renato Perini is currently offline Renato PeriniFriend
Messages: 6
Registered: January 2012
Junior Member
Ah, ok thanks.
Re: Syntax clarification. [message #792244 is a reply to message #787696] Mon, 06 February 2012 19:51 Go to previous messageGo to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Hi Christian,
Which document contains the information you've given?

Kind regards
Seref
Re: Syntax clarification. [message #792324 is a reply to message #792244] Mon, 06 February 2012 22:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

welcome to OMG Monster Specs

http://www.omg.org/spec/OCL/2.3.1/

Quote:
The value of a property on an object that is defined in a class diagram is specified in an OCL expression by a dot
followed by the name of the property. For example:
context Person inv:
self.isMarried


Quote:
Collections, like Sets, OrderedSets, Bags, and Sequences are predefined types in OCL. They have a large number of
predefined operations on them. A property of the collection itself is accessed by using an arrow '->' followed by the name
of the property.


Quote:
Shorthand for Collect
Because navigation through many objects is very common, there is a shorthand notation for the collect that makes the
OCL expressions more readable. Instead of
self.employee->collect(birthdate)
we can also write:
self.employee.birthdate


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 06 February 2012 22:15]

Report message to a moderator

Re: Syntax clarification. [message #792572 is a reply to message #792324] Tue, 07 February 2012 06:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You may find slide 47 from
http://www.slideshare.net/EdWillink/enrich-your-models-with-ocl helpful.

The OCL specification lacks a clear exposition here.

In OCL, you always use "." to navigate from an object and "->" to
navigate from a collection. Everything else is a shorthand.

[To add confusion, various languages influenced by OCL use "." for
collection navigation and eliminate the shorthands.]

Regards

Ed Willink


On 06/02/2012 22:13, Christian Dietrich wrote:
> Hi,
>
> welcome to OMG Monster Specs
>
> http://www.omg.org/spec/OCL/2.3.1/
>
> Quote:
>> Collections, like Sets, OrderedSets, Bags, and Sequences are
>> predefined types in OCL. They have a large number of
>> predefined operations on them. A property of the collection itself is
>> accessed by using an arrow '->' followed by the name
>> of the property.
>
>
> Quote:
>> Shorthand for Collect
>> Because navigation through many objects is very common, there is a
>> shorthand notation for the collect that makes the
>> OCL expressions more readable. Instead of
>> self.employee->collect(birthdate)
>> we can also write:
>> self.employee.birthdate
>
>
> ~Christian
Re: Syntax clarification. [message #792725 is a reply to message #792324] Tue, 07 February 2012 10:38 Go to previous messageGo to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
Thanks Christian,
After some struggling I've figured out that OCL is heavily used in Acceleo Smile
Time to read some specs.

Re: Syntax clarification. [message #792728 is a reply to message #792725] Tue, 07 February 2012 10:39 Go to previous messageGo to next message
Seref Arikan is currently offline Seref ArikanFriend
Messages: 73
Registered: August 2010
Member
By the way, is anybody else getting "connection was reset" type of error pages while accessing eclipse forums? I've been seeing it the last two days from different locations. (I'm at London, UK)?
Re: Syntax clarification. [message #793559 is a reply to message #792728] Wed, 08 February 2012 09:34 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Seref,

"OCL is heavily used in Acceleo" : well, Acceleo is an implementation of the MOFM2T OMG specification ... which is a "superset" of OCL, so yes we do have somewhat of a binding to OCL Smile.

as for the random "connection reset", we do get it a lot to from another Europe location (France)... I'll try and see if the webmasters are aware.

Laurent Goubet
Obeo
Previous Topic:[Acceleo] Unable to find module?
Next Topic:[Acceleo] Can I modify a section of a template from another section?
Goto Forum:
  


Current Time: Thu Mar 28 22:09:12 GMT 2024

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

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

Back to the top