Making D Lang More easy.
Jonathan M Davis
jmdavisProg at gmx.com
Sun May 15 15:42:35 PDT 2011
On 2011-05-15 08:13, Matthew Ong wrote:
> Hi All that help and provided good working instructions,
>
> The ugly build trail is due to the D-IDE setting problem in windows
> vista. The eclipse version that Mafi shown is working fine now and
> able to allow me to specify -lib option.
>
> The importing issue is due to the manner that D can only allow single
> file for single module. :( (Moving from Java) multiple file per
> package(module) is allowed and easy for handling large projects.
A package and a module are completely different. D has packages _exactly_ like
Java does, and they both do them the same. All of the modules in a folder are
part of the same package. Java also does only one module per file. The
difference is that Java enforces that every public class be in its own module.
So, you end up with a situation where every module represents a public class -
so much so that a compiled module in Java results in a .class file.
Now, Java doesn't use the term module, but the way their package system is
very similar to D - including packages - except that they are far more
restrictive about what goes in an individual module / source file. The result
is a proliferation of modules / source files.
Thinking of a Java package and a D module as the same thing is going to get
you into trouble if you ever have to do anything with package-level access. A
Java package is essentially a D package, and a Java source file is essentially
a D source file / module. It's just that Java has greater restrictions on what
goes in a source file, forcing you to create a lot of them.
So, porting Java code to D either means that you either have a lot of
extraneous modules with a single class in each, or you merge source files to
reduce the number of files / modules that you have.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list