how to determine of a module or any other symbol is visible?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Jun 18 18:17:00 UTC 2018


On Monday, June 18, 2018 11:53:50 Cauterite via Digitalmars-d-learn wrote:
> On Monday, 18 June 2018 at 09:28:00 UTC, rikki cattermole wrote:
> > On 18/06/2018 9:24 PM, Mr.Bingo wrote:
> >> On Monday, 18 June 2018 at 09:10:59 UTC, rikki cattermole
> >> wrote:
> >> This doesn't work with depreciation warnings.
> >
> > There won't be a way to check for those (I think).
> > Easier to not worry about them until it turns into errors.
>
> you can try the -de flag:
>
> // foo.d:
> deprecated void foo() {}
> pragma(msg, __traits(compiles, foo()));
>
> ---
>
> dmd foo.d
> -> true
>
> dmd -de foo.d
> -> false
>
> ---
>
> couldn't think of any examples of deprecated visibility to try
> though

Turning things into errors affects type introspection - e.g. the result on
__traits(comiles, ...) - so it's usually a bad idea. It's bad enough that -w
is a compiler flag without adding -de into the mix. That just makes it easy
to end up with code that doesn't compile or takes an unintended branch of a
static if, because a symbol was recently deprecated, and the code hasn't
been updated yet.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list