| Syntax clarification. [message #787662] |
Tue, 31 January 2012 16:07  |
John Doe Messages: 5 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 #792324 is a reply to message #792244] |
Mon, 06 February 2012 17:13   |
Christian Dietrich Messages: 4387 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
[Updated on: Mon, 06 February 2012 17:15] Report message to a moderator
|
|
|
| Re: Syntax clarification. [message #792572 is a reply to message #792324] |
Tue, 07 February 2012 01:05   |
Ed Willink Messages: 3151 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03231 seconds