Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » Syntax clarification.
Syntax clarification. [message #787662] Tue, 31 January 2012 16:07 Go to next message
Eclipse UserFriend
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 16:59 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Syntax clarification. [message #788055 is a reply to message #787696] Wed, 01 February 2012 04:44 Go to previous messageGo to next message
Eclipse UserFriend
Ah, ok thanks.
Re: Syntax clarification. [message #792244 is a reply to message #787696] Mon, 06 February 2012 14:51 Go to previous messageGo to next message
Eclipse UserFriend
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 17:13 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Mon, 06 February 2012 17:15] by Moderator

Re: Syntax clarification. [message #792572 is a reply to message #792324] Tue, 07 February 2012 01:05 Go to previous messageGo to next message
Eclipse UserFriend
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 05:38 Go to previous messageGo to next message
Eclipse UserFriend
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 05:39 Go to previous messageGo to next message
Eclipse UserFriend
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 04:34 Go to previous message
Eclipse UserFriend
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 May 15 10:06:41 EDT 2025

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

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

Back to the top