Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Extending operator semantics
Extending operator semantics [message #924870] Thu, 27 September 2012 07:40 Go to next message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Using MDT/OCL sources downloaded from Git, I try to extend the semantic of several operators like for example 'not'

Using completeocl, when I try to define this constraint

Context Test
inv not_5: 
not 5

I has this error "Unresolved Operation 'UnlimitedNatural::not()'"
and this is right for completeocl.
However, for the semantic of my DSL, I can write this.
I don't know what is the element that should be extended:
the semantic of the 'not' operator
or of the semantic of data type (like in this case, UnlimitedNatural).

Thanks

[Updated on: Thu, 27 September 2012 07:55]

Report message to a moderator

Re: Extending operator semantics [message #924949 is a reply to message #924870] Thu, 27 September 2012 09:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Provided you use the new Pivot-based OCL you should be able to do

context UnlimitedNatural
def not() : UnlimitedNatural ...

but I cannot discourage you strongly enough.

Overloading built-in operators is guaranteed to be non-portable to other
OCLs and is highly dubious.

There is a clear ambiguity between bit-wise and logical not that merit
names that the reader can actually understand.

Regards

Ed Willink


On 27/09/2012 08:40, Fy Za wrote:
> Using MDT/OCL sources downloaded from Git, I try to extend the
> semantic of several operators like for example 'not'
>
> Using completeocl, when I try to define this constraint
>
>
> Context Test
> inv not_5: not 5
>
> I has this error "Unresolved Operation 'UnlimitedNatural::not()'"
> and this is right for completeocl.
> However, for the semantic of my DSL, I can write this.
> I don't know what is the element that should be extended:
> the semantic of the 'not' operator or of the semantic of data type
> (like in this case, UnlimitedNatural).
>
> Thanks
>
>
Re: Extending operator semantics [message #927152 is a reply to message #924949] Sat, 29 September 2012 10:07 Go to previous message
Fy Za is currently offline Fy ZaFriend
Messages: 245
Registered: March 2010
Senior Member
Thank you for reply,

However, I don't know where I should write this definition!

I tried to make it in
/org.eclipse.ocl.examples.pivot/model/Types.ocl but the same error is shown (of course, after generate all editors).

I don't like define a semantic of the operator not with UnlimitedNatural type.
I 'd like just write it to be after parsed.

Also, I don't find classical definitions (like for example not operator with Boolean type)


Thanks
Fy Za

[Updated on: Sat, 29 September 2012 10:09]

Report message to a moderator

Previous Topic:[Announce] Eclipse OCL 4.0.1 (Juno SR1) is now available
Next Topic:Pivot oclContainer() result doesn't expose navigable properties
Goto Forum:
  


Current Time: Tue Apr 16 20:11:36 GMT 2024

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

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

Back to the top