std_exception.html#enforce: example does not compile

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Jan 27 16:10:29 UTC 2018


On Saturday, January 27, 2018 13:29:00 kdevel via Digitalmars-d-learn wrote:
> What's wrong here? And why is the "selective import" of enforce
> necessary?

Because you named your module enforce. As such, by default, referring to
enforce inside of the module refers to the module. Having the selective
import overrides that.

It's generally not a good idea to name your module the same name something
that you would refer to inside the module. It's usually not an issue in real
programs, because in that case, aside from maybe the module with main,
modules aren't at the top-level, but if you're doing something like naming
your test program after a function that you're using in it, you're going to
have problems.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list