Syntax clarification. [message #787662] |
Tue, 31 January 2012 16:07  |
Eclipse User |
|
|
|
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 #792572 is a reply to message #792324] |
Tue, 07 February 2012 01:05   |
Eclipse User |
|
|
|
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.08178 seconds