What exactly module in D means?

Andre Tampubolon via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jul 5 09:35:22 PDT 2014


I've been reading the newsgroup for a while, and it seems that one of 
the reason folks like D is because it supports module.

My question is: what does module mean?
A quick google pointed my this page: http://dlang.org/module.html.
Still cannot understand it, though :)

How does it differ from the old C's #include?

For example, consider the hello world in C.

#include <stdio.h>

int main(void){
	printf("%s\n", "Hello world...");
	return 0;
}

The C preprocessor while replace the line "#include <stdio.h>" with the 
content of stdio.h itself.

While in D:

import std.stdio;

void main(){
	writeln("Hello world...");
}

Does that mean the compiler take the "definition" of writeln itself from 
stdio.d and paste it into my program? Pardon my ignorance, because I'm 
not versed in compiler theory.


More information about the Digitalmars-d-learn mailing list