Making D Lang More easy.

Jonathan M Davis jmdavisProg at gmx.com
Wed May 11 10:03:34 PDT 2011


On 2011-05-11 09:26, Mafi wrote:
> Am 11.05.2011 18:17, schrieb Jonathan M Davis:
> > On 2011-05-11 07:22, Mafi wrote:
> >> The module system has been given much attention so that the import order
> >> doesn't matter and you cannot use an ambigous symbol without error.
> >> Because there's no VM, you have to import everything you want to use.
> >> If you know C++, think of it like #include and using namespace x; at the
> >> same time.
> >> http://d-programming-language.org/module.html#ImportDeclaration
> > 
> > That's an odd comment to make. D's import is very similar to Java's
> > import and is far more like Java's import than C/C++'s #include. D is
> > probably pickier about possible name conflicts, but in general,
> > importing in D and Java and pretty much the same. You're specifically
> > importing _modules_ in D, and D doesn't enforce 1 public class per file,
> > so the syntax is a bit different when importing specific classes rather
> > than a whole module, and you do have to deal with the possibility of
> > conflicting free functions whereas they aren't even legal in Java, but
> > overall importing in Java and D and pretty similar. I don't know why
> > you'd be comparing D's import to C/C++'s #include rather than Java's
> > import.
> > 
> > - Jonathan M Davis
> 
> (Note that I meant #including .h-files)
> What I wanted to make absolutely clear is that you can't just say
> java.util.ArrayList without explicitely importing java.util in D. It is
> possible in Java but not in D.
> Importing in Java is like 'using some_class;' in C++.

Well, in a way. The issue is that in Java, you must have one public class per 
file, whereas in D, you can have whatever you want in a module. So, you're 
specifically importing a file in either case. It's just that Java is much more 
fine-grained about what goes in a file. But I see what you're saying. In that 
sense, D is more like C++. The import mechanism is very similar between the 
two, but the difference in how files are laid out does definitely change 
things.

- Jonathan M Davis


More information about the Digitalmars-d mailing list