|
Re: OCL closures implementation [message #59220 is a reply to message #59195] |
Mon, 14 July 2008 19:59 |
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. 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. At least, I haven't tried very hard ;-)<BR>
<BR>
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:<BR>
<BR>
1. Collect the body-expression values on the original source collection<BR>
S into a new set R'.<BR>
--> initialize the over-all closure result R to this set R'<BR>
2. For new elements added to R in the previous pass (previous R' set),<BR>
collect the body-expression values into a new set R'.<BR>
--> add these results to R<BR>
3. Repeat step 2 until R' has no results not already in R (i.e.,<BR>
R' - R is the empty-set)<BR>
<BR>
AFAIK, closure was never raised as a requested capability in the OCL specification. 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--
|
|
|
Powered by
FUDForum. Page generated in 0.03259 seconds