Namespace qualifiers and name collisions

0 views
Skip to first unread message

Jörn Guy

unread,
Oct 30, 2007, 8:28:53 PM10/30/07
to Tefkat
I have a metamodel that contains cross references across packages. I
have an "instance" package, which contains model elements representing
samples for testing, and a "type" package, that contains model
elements describing the types that the instance have to comply with.
In order to make local operation simple, I reuse terms. hence there is
a type/Vector and an instance/Vector. I was wondering how I would
address these in the bindings of Tefkat rules?

If I do

NAMESPACE type
NAMESPACE instance

"Vector" will always resolve to type/Vector..

I would assume that their may be many cases in practice where such
namespace collisions occur. Especially, since the models may be
created seperately and certain popular 'pattern-like' terms like
'NamedElement' are bound to reappear...

michael lawley

unread,
Oct 30, 2007, 9:07:13 PM10/30/07
to Tef...@googlegroups.com
Hi Jörn,

If you do the below, then "Vector" will be ambiguous - you have two
options. One is to use the fully-qualified type name; assuming the
name of the package containing Vector in the metamodel "type" is
"type", and similarly for the metamodel "instance", then you would
write fully-qualified names ::type::Vector and ::instance::Vector to
disambiguate them. The alternative is to import the metamodels into
different namespaces (this is required when the fully-qualified names
are the same, as may occur with different versions of the same
metamodel). Thus:

NAMESPACE t type
NAMESPACE i instance

RULE matchVectors
FORALL i^Vector inst, t^Vector type
WHERE conforms(inst, type)
MAKE println(inst, type)
;

Thus, two namespaces ("t" and "i") are defined for the transformation
and are populated by the names (simple and fully qualified) from the
associated metamodels.

michael

Reply all
Reply to author
Forward
0 new messages