[sc34wg3] [CTM issue] Consistent name clash handling

Xuân Baldauf xuan--sc34wg3--isotopicmaps.org at baldauf.org
Wed Oct 15 06:22:26 EDT 2008


When digesting the CTM tutorial at the TMRA 2008 (thanks to Lars Heuer),
these issues arised to me:

(In subsequent discussion, related issues also arised to others.)

When including files, the question arises how to treat name clashes,
like the following:

   1. case 1
          * file1.ctm:
            %prefix foo http://bar/1/
          * file2.ctm:
            %prefix foo http://bar/2/
          * file3.ctm:
            %include file1.ctm
            %include file2.ctm
            %prefix foo http://bar/3/
            foo:some_topic
   2. case 2
          * file1.ctm:
            def foo() http://bar1/some_topic end
          * file2.ctm:
            def foo() http://bar2/some_topic end
          * file3.ctm:
            %include file1.ctm
            %include file2.ctm
            def foo() http://bar3/some_topic end
            foo()

As far as I understand, case 1 yields a topic map with one topic with
"http://bar/3/some_topic" as identifier. Does case 2 yield a topic map
with one topic with "http://bar/3/some_topic" as identifier, too?

Then, how about this example?

   1. case 1
          * file1.ctm:
            %prefix foo http://bar/1/
          * file2.ctm:
            %prefix foo http://bar/2/
          * file3.ctm:
            %include file1.ctm
            %include file2.ctm
            foo:some_topic
   2. case 2
          * file1.ctm:
            def foo() http://bar1/some_topic end
          * file2.ctm:
            def foo() http://bar2/some_topic end
          * file3.ctm:
            %include file1.ctm
            %include file2.ctm
            foo()

Does case 1 yield an error? Does case 2 yield an error?

I think that name clashes should be treated equally, regardless whether
it is a prefix name clash or a template name clash.

I'd opt for the following:

    * In general, names are propagated up from included files into the
      namespace of the including file.
    * If the same name is redefined in the including file, then this
      name takes precedence for that file
    * If two names clash (e.g. in file3.ctm), then
          o the names are retained if their content is the same (for
            prefixes, if the URL they point to is the same, for
            templates, if their execution would be the same, more
            specifically if their (string) content and scope (e.g. what
            prefixes are valid for them) are the same)
          o the names cancel each other out if their content is
            different. This means that the name is treated at the
            including file as if it is not defined. (This means: If the
            name is dereferenced, there is an error (but maybe a more
            specific error message saying that there have been
            candidates, but they are ambiguous). If the name is defined
            in the including, then it is overridden.)

This suggestion also solves the following use case:

    * file0.ctm:
      def foo($param) ... end
    * file1.ctm:
      %include file0.ctm
      foo(...)
    * file2.ctm:
      %include file0.ctm
      foo(...)
    * file3.ctm:
      %include file1.ctm
      %include file2.ctm
      foo()

Currently, after "%include file2.ctm", the CTM parser creates an error
because template "foo" is doubly-defined. This defeats the purpose of
templates and including: to centralize common templates or common
patterns into a central file ("file0.ctm" in this case).

ciao,
Xuân.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.isotopicmaps.org/pipermail/sc34wg3/attachments/20081015/9735138d/attachment.htm 


More information about the sc34wg3 mailing list