Find symbol in unknown module at compile time?

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 6 22:25:35 PST 2014


On Sun, 07 Dec 2014 05:42:31 +0000
bitwise via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

what you actually want is some cross-module compile-time data storage.
this is impossible to implement. at least to make it reliable.

with separate compilation, for example, you can't get list of "all
modules", 'cause we can link other unimported modules to the final
executable. this is somethimes useful with "extern", for example.

and there is no such thing as "main module" too, so there is no "root"
for symbols.

besides, some templates can be not instantiated at the time you doing
compile-time reflection, for example. that is why my console-ng
requires that "register all" mixin must be the last line in the module.

with some efforts and hackery you can walk all imported modules, but
this can fail at unexpected places.

tl;dr: things aren't that easy when it comes to compile-time
reflection. either live that to runtime or write compile-time wrappers
and restrict compile-time reflection usage to well-defined places and
patterns.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141207/6c5e78f9/attachment.sig>


More information about the Digitalmars-d mailing list