[Issue 5309] Add language support for external D symbols refs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jul 8 12:10:54 UTC 2021


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

Dlang Bot <dlang-bot at dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot at dlang.rocks> ---
@Geod24 created dlang/dmd pull request #12839 "Fix 5309 - Support `extern(D)`
symbol refs" fixing this issue:

- Fix 5309 - Support `extern(D)` symbol refs

  Currently, `extern(D)` is quite incomplete: An `extern(D)` symbol is mangled
  as if it was in the module it is declared in, while users usually want to
  declare a function or type that lives in another module.

  Borrowing from the syntax that was adopted for `extern(C++, name.space)`, we
introduce `extern(D, pkg.mod)`.
  Note that, unlike `extern(C++)`, no string alternative is needed:
  the motivation for the string variant was that C++ namespaces could be D
keywords,
  hence some namespaces could not be bound with the identifier variant,
  a problem which obviously does not apply to `extern(D)` symbols.

  The need for this functionality is easily demonstrated by druntime's
`externDFunc`.
  `core.internal.traits : externDFunc` is a template that defines an
`extern(D)` symbol in another module.
  This is currently done by using `pragma(mangle)` along with `core.demangle :
mangleFunc`.

  And as it turns out, the only reason for `core.demangle : mangleFunc` to
exists is for `externDFunc`.
  Hence, implementing this functionality will greatly simplify a core piece of
druntime:
  `core.demangle : mangle` (and its derivatives, including `mangleFunc` and
`externDFunc`) can be removed
  and replaced by `XXX.mangleof`, relying on the compiler instead of a library
function which have to be
  kept in sync with the compiler implementation.

https://github.com/dlang/dmd/pull/12839

--


More information about the Digitalmars-d-bugs mailing list