www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17750] New: DMD should consider namespaces when validating


          Issue ID: 17750
           Summary: DMD should consider namespaces when validating
                    declaration names
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: roman hargrave.info

In writing bindings for libtorch, a C++ machine learning framework, I ran in to
a seemingly artificial limitation.

I need to define external linkage for members of a class named Torch::Object.
Unfortunately, the compiler will not let you declare a class named `Object`
even if it is defined such that it would not collide with D's own Object the
only "clean" way to do this (and only for non-virtual functions) is by manually
specifying symbol names for each method with `pragma(mangle, ...)`.

If fixing this by changing the validation logic actually presents issues,
perhaps adding a pragma, like mangle, that tells the compiler what class name
to use when generating C++ symbols would be a good solution.

Aug 12 2017