[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.mdt.ocl] Re: def expression?

Ed,
I've been trying to get familiar with nested environments, You promised that they were easy to use ;), but unfortunately I can't find code examples--at least not any that point in the direction that I need to go.


In short, my problem is that I match a graph pattern to a model and, during the matching process, I need a scope that constantly reflects the bound nodes by bound variables, i.e. the scope must contain a bound variable per named node that is currently bound.

While I backtrack, I need to remove variables from my environment/scope that will possibly be added again. So, you suggest to do this with nested environments--How do I create a nested environment (I think I understood that...) and how to I go back to an outer environment when I backtrack?

Thanks for helping!

Joel


Ed Willink wrote:
Hi Joel
I'm not sure about your whole problem but when you mention removing variables from environments I get very uncomfortable.

Why is that?

It means that the Environment has a very clear locality. Nested environments are always valid for the context that initialised them.


Note that OCL 2.0 does not support remove of elements from an Environment.

It is much easier
to created a nested environment for the nested scope and revert to the
outer ebvironment when you want to recover context.

You'll find nested environments are easy too, and you cannot forget to match your adds with removes.

I haven't worked with these nested environments yet, but I'll keep it in mind. However, I'd have to create a nested environment for each variable that I add. Adding and removing variables is easy and works well for me so far.

If it works for you fine. Just beware that if you start to do more interesting things, it might bite later.


    Regards

Ed Willink