If you're familiar with Java or C++ you should not find it odd at all.
Just exchange self/this. The semantics of name visibility/usage are very
similar (until you get to implicit source for iterators).
self/this is an instance of the class, and parameters are local variables.
On 13/01/2011 16:35, Andreas Maier wrote:
> Here is another question that did not become clear to me when
> consulting the OMG OCL 2.0 spec:
> 7.3.4 "Pre- and Postconditions" states:
> "The contextual instance self then is an instance of the type that
> owns the operation or method as a feature."
> It then goes on to give the example:
> context Typename::operationName(param1 : Type1, ... ): ReturnType
> pre : param1 > ...
> post: result = ...
> The spec text (as I understand it) states that the context is an
> instance of a class.
> The context statement of the example suggests (to me) that the context
> is the operation itself.
> The OCL body of the example accesses the parameters without any usage
> of "self".
> That is all a bit inconsistent to me, but maybe I just don't
> understand it right.
> I'd like to understand what "self" in a precondition resolves to. My
> assumption is it resolves to the instance the method is invoked on.
> I'd like to understand how to access the value of a parameter of a
> method invocation on an instance. Does that not need to start with
> "self" ?