__FILE__ and __LINE__ in case of import expression
Adam D. Ruppe
destructionator at gmail.com
Fri Aug 21 15:27:14 UTC 2020
On Friday, 21 August 2020 at 14:01:24 UTC, Andrey Zherikov wrote:
> mixin(import("foo.d")); // line #17 (2)
Why are you doing this? This kind of thing is almost never an
ideal solution in D.
See, the compiler just sees a big string literal there. It isn't
a separate file at that point, the import expression just pastes
in the file contents as a string, and then mixin makes a chunk of
code from it.
These two features are not really meant to be used together, at
least not without some custom translation code in the middle.
More information about the Digitalmars-d-learn
mailing list