Home » Modeling » OCL » Using OCL for creating (temporary) object
Using OCL for creating (temporary) object [message #1130136] |
Wed, 09 October 2013 08:52 |
Kirsten M. Z. Messages: 132 Registered: July 2010 |
Senior Member |
|
|
Hi @all,
first, I have a more general question about an OCL feature I am missing. I recently recognized that it is not possible to create objects using OCL. To be honest, I was surprised. Or did I just miss this feature? I could not find any example or according documentation. Has this ever been in an OCL specification? Are there any (theoretical) issues/problems?
I have worked with Eclipse QVTo before, which is based on OCL resp. imperative OCL. It is common to create objects there, e.g. via
object ObjectType { name = 'objectName', attribute1 = 1, ... }
Maybe this feature is not that important in a regular OCL. However, why not having this feature? For example, there is no problem to create/use (temporary) collections or tuples:
let x : Tuple(name : String, att1 : Integer) = Tuple {name = 'a_name', attribute1 = 1} in ...
Another area of application would be a derived feature (or query method, no side effect), which is defined using OCL. The feature shall return a "derived" object, i.e., a data set based on a defined class type. Without the possibility to create the data set, this is not possible?
In addition, if creation would be possible, are there any EMF related problems? For example, if OCL (non-Pivot) is extended by such a feature, and EMF objects must be created (OclInEcore).
|
|
|
Re: Using OCL for creating (temporary) object [message #1130187 is a reply to message #1130136] |
Wed, 09 October 2013 09:47 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
This is https://bugs.eclipse.org/bugs/show_bug.cgi?id=293622 (2009),
http://www.omg.org/issues/ocl2-rtf#Issue13057 (2008).
If you read Bug 293622, you can see how my thinking has evolved so that
the side-effect-free issue is solved.
If OCL had had type constructors when QVTo was formulated, QVTo could
have been simpler.
The Pivot-based Eclipse OCL has a prototype implementation of type
constructors re-using the Tuple syntax. Currently it creates objects,
with a memory side effect; multiple creations return multiple objects,
except that if you use the OCL to Java code generator the Common
Subexpression Elimination may kick in. Consequently
"MyClass{name='mine'}=MyClass{name='mine'}" may be true or false
depending on your execution context.
The bug is still open since there is more work to do, but for typical
simple cases it may be useful.
This facility is unlikely to be available in the classic OCL.
There is no particular interaction with EMF, except that if you want to
construct an EDataType, you must implement createFromString to support
e.g. "EDate{'1-Jan-2013'}".
Regards
Ed Willink
On 09/10/2013 09:52, Kirsten M. Z. wrote:
> Hi @all,
>
> first, I have a more general question about an OCL feature I am
> missing. I recently recognized that it is not possible to create
> objects using OCL. To be honest, I was surprised. Or did I just miss
> this feature? I could not find any example or according documentation.
> Has this ever been in an OCL specification? Are there any
> (theoretical) issues/problems?
>
> I have worked with Eclipse QVTo before, which is based on OCL resp.
> imperative OCL. It is common to create objects there, e.g. via
>
> object ObjectType { name = 'objectName', attribute1 = 1, ... }
>
> Maybe this feature is not that important in a regular OCL. However,
> why not having this feature? For example, there is no problem to
> create/use (temporary) collections or tuples:
>
> let x : Tuple(name : String, att1 : Integer) = Tuple {name = 'a_name',
> attribute1 = 1} in ...
>
> Another area of application would be a derived feature (or query
> method, no side effect), which is defined using OCL. The feature shall
> return a "derived" object, i.e., a data set based on a defined class
> type. Without the possibility to create the data set, this is not
> possible?
>
> In addition, if creation would be possible, are there any EMF related
> problems? For example, if OCL (non-Pivot) is extended by such a
> feature, and EMF objects must be created (OclInEcore).
|
|
| | |
Goto Forum:
Current Time: Thu Mar 28 12:34:07 GMT 2024
Powered by FUDForum. Page generated in 0.05067 seconds
|