Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » LET and IN
LET and IN [message #490136] Wed, 07 October 2009 13:06 Go to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

As I commented in another thread I don't get LET expressions working.
For example the following:

let aspectParams: Set(MyMetaModel::Parameter) =
self.parentIf.parentAspect.events->forAll(ev|
ev.parameter->union(aspectParams)
)
in
aspectParams->includes(self.boolParam)

With that expression I want to check if the referenced boolParam is one
of the parameters of the earlier referenced events of a parent class of
the context class. I get the error in the ocl interpreter example
console that aspectParams isn't recognized. Why does it come as the code
completion does work if I use aspectParams. Another question: is the
above expression correct, especially the generation of the aspectParams
with the recursive union operation?
Re: LET and IN [message #490319 is a reply to message #490136] Thu, 08 October 2009 10:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Gilbert

The error is correct.

You cannot reference aspectParams as the union argument while
initializing it.

Regards

Ed Willink


Gilbert Mirenque wrote:
> As I commented in another thread I don't get LET expressions working.
> For example the following:
>
> let aspectParams: Set(MyMetaModel::Parameter) =
> self.parentIf.parentAspect.events->forAll(ev|
> ev.parameter->union(aspectParams)
> )
> in
> aspectParams->includes(self.boolParam)
>
> With that expression I want to check if the referenced boolParam is one
> of the parameters of the earlier referenced events of a parent class of
> the context class. I get the error in the ocl interpreter example
> console that aspectParams isn't recognized. Why does it come as the code
> completion does work if I use aspectParams. Another question: is the
> above expression correct, especially the generation of the aspectParams
> with the recursive union operation?
Re: LET and IN [message #490377 is a reply to message #490319] Thu, 08 October 2009 13:51 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Hi Ed,

> You cannot reference aspectParams as the union argument while
> initializing it.
>
Makes sense. I thought the error comes from the latter code. Can you
help me with getting a correct initialization of the aspectParams?
Re: LET and IN [message #490486 is a reply to message #490377] Thu, 08 October 2009 19:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Gilbert

I'm not sure what you're trying to do but if you want an updating
accumulator, you probably want to use iterate.

Ed


Gilbert Mirenque wrote:
> Hi Ed,
>
>> You cannot reference aspectParams as the union argument while
>> initializing it.
>>
> Makes sense. I thought the error comes from the latter code. Can you
> help me with getting a correct initialization of the aspectParams?
Re: LET and IN [message #490517 is a reply to message #490486] Thu, 08 October 2009 22:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

But how can I add elements to the Set without using the Set?
Re: LET and IN [message #490622 is a reply to message #490517] Fri, 09 October 2009 12:54 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 847
Registered: July 2009
Senior Member
--=-ovMenT8G8bPR0qVDeOPU
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Gilbert,

Try something like this:

let aspectParams: Set(MyMetaModel::Parameter) =
self.parentIf.parentAspect.events.parameter->asSet()
in
aspectParams->includes(self.boolParam)

All you need is a collect iterator, which is implicit in the dot
navigation.

HTH,

Christian


On Fri, 2009-10-09 at 00:06 +0200, Gilbert Mirenque wrote:

> But how can I add elements to the Set without using the Set?

--=-ovMenT8G8bPR0qVDeOPU
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.24.1.1">
</HEAD>
<BODY>
Hi, Gilbert,<BR>
<BR>
Try something like this:<BR>
<BR>
<TT>&nbsp;&nbsp;&nbsp; </TT><TT><FONT COLOR="#000000">let aspectParams: Set(MyMetaModel::Parameter) =</FONT></TT><BR>
<TT><FONT COLOR="#000000"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; self.parentIf.parentAspect.events.parameter-&gt;</FONT> </TT><TT>asSet()</TT><BR>
<TT>&nbsp;&nbsp;&nbsp; </TT><TT><FONT COLOR="#000000">in</FONT></TT><BR>
<TT>&nbsp;&nbsp;&nbsp; </TT><TT><FONT COLOR="#000000">aspectParams-&gt;includes(self.boolParam) </FONT></TT><BR>
<BR>
All you need is a collect iterator, which is implicit in the dot navigation.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
<BR>
On Fri, 2009-10-09 at 00:06 +0200, Gilbert Mirenque wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
But how can I add elements to the Set without using the Set?
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-ovMenT8G8bPR0qVDeOPU--
Re: LET and IN [message #490964 is a reply to message #490622] Mon, 12 October 2009 15:41 Go to previous message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

> All you need is a collect iterator, which is implicit in the dot
> navigation.
Ah Ok, thank you very much
Previous Topic:N00b OCL expression question to compare URI
Next Topic:Extending OCL standard library with function returning Sequence(T)
Goto Forum:
  


Current Time: Mon Dec 22 00:44:00 GMT 2014

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

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