Private imports and Objects

helxi brucewayneshit at gmail.com
Thu Nov 30 06:29:43 UTC 2017


1. Why are imports visible from outside the package when you do 
selective imports?

//mod.d
module mod;

import std.stdio : writeln;

public void greet()
{
     writeln("Hello");
}


//app.d
import mod;

void main()
{
	mod.greet();
	writeln("You should not be seeing this.");

}

Compiles just fine and prints "You should not be seeing this." 
just fine with `$dub build`. Even if I use package imports the 
result stays the same.

2. Classes that do not inherit (base classes) actually inherit 
from 'Object`. For which, often times one converts the Object to 
its subclasses. What's the rationale behind this?
Isn't this going to add overhead?




More information about the Digitalmars-d-learn mailing list