https://issues.dlang.org/show_bug.cgi?id=17750

          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: nob...@puremagic.com
          Reporter: ro...@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.

--

Reply via email to