Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL closures implementation
OCL closures implementation [message #59195] Mon, 14 July 2008 15:23 Go to next message
Neil is currently offline Neil
Messages: 5
Registered: July 2009
Junior Member
I'm aware that closure is not defined in the spec for OCL 2. I'm not
clear why it's missing - too hard to implement or just not considered at
the time.

Is the implementation in Eclipse syntactic sugar for some variant of an
OCL recursive function with stopping criteria? Or is something more
involved being done behind the curtain?

I'm trying to use OCL in Eclipse to define queries over a graph-like
data structure (with possibly circular relations). So far the closure
operator works perfectly, but I want to clarify how it's doing this.

thanks
Neil Ernst
Re: OCL closures implementation [message #59220 is a reply to message #59195] Mon, 14 July 2008 15:59 Go to previous message
Eclipse User
Originally posted by: cdamus.zeligsoft.com

--=-N+taMvkZwfPa/fyg4M4k
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Neil,

Actually, the closure iterator isn't really syntactic sugar. The OCL
specification suggests (requires?) that for any iterator expression that
is added to the standard library (not sure what that means; the question
was raised as an issue), a specification of the iterator in terms of
existing iterators (or the iterate expression) be provided.

The closure iterator is recursive by nature, and I don't think that this
can be expressed using the iterate expression. At least, I haven't
tried very hard ;-)

The important stopping condition is the encountering of an object that
has already been added to the closure result collection before. This,
of course, is the classic means of dealing with recursion in cyclical
structures. The MDT implementation is roughly this:

1. Collect the body-expression values on the original source
collection
S into a new set R'.
--> initialize the over-all closure result R to this set R'
2. For new elements added to R in the previous pass (previous R' set),
collect the body-expression values into a new set R'.
--> add these results to R
3. Repeat step 2 until R' has no results not already in R (i.e.,
R' - R is the empty-set)

AFAIK, closure was never raised as a requested capability in the OCL
specification. Perhaps we should raise an enhancement issue?

HTH,

Christian


On Mon, 2008-07-14 at 15:23 -0400, Neil wrote:

> I'm aware that closure is not defined in the spec for OCL 2. I'm not
> clear why it's missing - too hard to implement or just not considered at
> the time.
>
> Is the implementation in Eclipse syntactic sugar for some variant of an
> OCL recursive function with stopping criteria? Or is something more
> involved being done behind the curtain?
>
> I'm trying to use OCL in Eclipse to define queries over a graph-like
> data structure (with possibly circular relations). So far the closure
> operator works perfectly, but I want to clarify how it's doing this.
>
> thanks
> Neil Ernst

--=-N+taMvkZwfPa/fyg4M4k
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Neil,<BR>
<BR>
Actually, the closure iterator isn't really syntactic sugar.&nbsp; The OCL specification suggests (requires?) that for any iterator expression that is added to the standard library (not sure what that means; the question was raised as an issue), a specification of the iterator in terms of existing iterators (or the iterate expression) be provided.<BR>
<BR>
The closure iterator is recursive by nature, and I don't think that this can be expressed using the iterate expression.&nbsp; At least, I haven't tried very hard&nbsp; ;-)<BR>
<BR>
The important stopping condition is the encountering of an object that has already been added to the closure result collection before.&nbsp; This, of course, is the classic means of dealing with recursion in cyclical structures.&nbsp; The MDT implementation is roughly this:<BR>
<BR>
&nbsp; 1. Collect the body-expression values on the original source collection<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; S into a new set R'.<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; --&gt; initialize the over-all closure result R to this set R'<BR>
&nbsp; 2. For new elements added to R in the previous pass (previous R' set),<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; collect the body-expression values into a new set R'.<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; --&gt; add these results to R<BR>
&nbsp; 3.&nbsp; Repeat step 2 until R' has no results not already in R (i.e.,<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; R' - R is the empty-set)<BR>
<BR>
AFAIK, closure was never raised as a requested capability in the OCL specification.&nbsp; Perhaps we should raise an enhancement issue?<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Mon, 2008-07-14 at 15:23 -0400, Neil wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">I'm aware that closure is not defined in the spec for OCL 2. I'm not </FONT>
<FONT COLOR="#000000">clear why it's missing - too hard to implement or just not considered at </FONT>
<FONT COLOR="#000000">the time.</FONT>

<FONT COLOR="#000000">Is the implementation in Eclipse syntactic sugar for some variant of an </FONT>
<FONT COLOR="#000000">OCL recursive function with stopping criteria? Or is something more </FONT>
<FONT COLOR="#000000">involved being done behind the curtain?</FONT>

<FONT COLOR="#000000">I'm trying to use OCL in Eclipse to define queries over a graph-like </FONT>
<FONT COLOR="#000000">data structure (with possibly circular relations). So far the closure </FONT>
<FONT COLOR="#000000">operator works perfectly, but I want to clarify how it's doing this.</FONT>

<FONT COLOR="#000000">thanks</FONT>
<FONT COLOR="#000000">Neil Ernst</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-N+taMvkZwfPa/fyg4M4k--
Previous Topic:UML and generate code
Next Topic:[Announce] MDT OCL 1.2.1 M200807161339 is available
Goto Forum:
  


Current Time: Sat Aug 30 02:25:14 EDT 2014

Powered by FUDForum. Page generated in 0.02196 seconds