Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [TCS] TCSRuntime doitForContext ambiguity
[TCS] TCSRuntime doitForContext ambiguity [message #12361] Mon, 21 April 2008 14:50 Go to next message
T Kruse is currently offline T KruseFriend
Messages: 73
Registered: July 2009
Member
Hi,

reading the code of TCSRuntime.RefSetting.doitForContext, I notice that in
order to resolve a reference in a context, you look within the context,
then do:

if(!done) {
context = context.parent();
if(context != null)
done = doItForContext(context);
}

So this looks to me as if in case no suitable modelelement was found in
the given context, you extend the search in the parent context.

My problem with that is: How would you find ambiguous references this way?
Meaning should there ever be two suitable candidates, on the current
context and one in the parent context, should TCS not rather report a
problem than taking the first candidate as reference?
Re: [TCS] TCSRuntime doitForContext ambiguity [message #12372 is a reply to message #12361] Mon, 21 April 2008 16:16 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

> So this looks to me as if in case no suitable modelelement was found in
> the given context, you extend the search in the parent context.
>
> My problem with that is: How would you find ambiguous references this
> way? Meaning should there ever be two suitable candidates, on the
> current context and one in the parent context, should TCS not rather
> report a problem than taking the first candidate as reference?

The notion of context in TCS is related to the notion of scope.
There cannot be collisions within a given scope, but an element defined
at a local scope may mask what exists in any outer scope.

A typical example is the C language, in which global variables are
visible in functions, but functions can mask global variables with local
variables. In this case, the overwall C file is a context, and so are
functions. Moreover, C supports arbitrary nesting of scopes (each
statement block defines a new one).

If you want to make sure an element cannot be masked, then you may only
define one global context (i.e., the root of the model).


Regards,

Frédéric Jouault
Previous Topic:[TCS] custom separators in KM3.tcs
Next Topic:[TCS] referTo by subtype property
Goto Forum:
  


Current Time: Sat Aug 31 23:20:58 GMT 2024

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

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

Back to the top