[TCS] TCSRuntime doitForContext ambiguity [message #12361] |
Mon, 21 April 2008 10:50  |
Eclipse User |
|
|
|
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 12:16  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02806 seconds