DIP61: Add namespaces to D

Andrej Mitrovic via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 27 01:16:49 PDT 2014


On 4/27/14, Dicebot via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
> Using named mixin templates for pure scope resolution is side
> effect and should be discouraged in any reasonable code.

There's also the un-instantiable class trick:

-----
final abstract class Scope
{
static:
}
-----

A struct-based version is also possible. It's used in Phobos and other
libraries. There's a need for scoping symbols other than in modules,
but I'm not a fan of pushing C++ features in D. Not unless we have a
really solid DIP.

Idealism aside, modules have some implementation issues right now
which force people to use workarounds like named mixins or the above
trick, e.g. package access not being propagated up/down a hierarchy.


More information about the Digitalmars-d mailing list