Bug 22578 – Symbols exposed by means of compile-time evaluation are not eligible for selective imports.

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-12-07T19:34:52Z
Last change time
2024-12-13T19:19:41Z
Assigned to
No Owner
Creator
Andrei Alexandrescu
Moved to GitHub: dmd#20018 →

Comments

Comment #0 by andrei — 2021-12-07T19:34:52Z
This may not be fixable either on principle or on account of being too onerous to implement or support. Among the implementation mechanisms for versioning (see e.g. https://github.com/dlang/phobos/pull/8309) we need a means to expose symbols in a controlled manner. One possibility is to do so programmatically by means of introspection and code generation, e.g.: static foreach (s; __traits(allMembers, canon!"std")) { mixin("alias "~s~" = canon!`std`."~s~";"); } This code exposes symbols such as `std.algorithm.comparison.canon!"std".among` as `std.algorithm.comparison.among`. It has the usual automation advantages compared with repeated alias directives: alias among = canon!"std".among; ... However (and this is the subject of this issue), symbols exported by means of `static foreach` and `mixin` are not usable in selective imports. For example, if another module attempts: import std.algorithm.comparison : among; then the symbol exposed with a plain `alias` will work, but the symbol exposed programmatically will not.
Comment #1 by robert.schadek — 2024-12-13T19:19:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20018 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB