module vs import
kb3ctd2 at yahoo.com
Sun Jun 8 10:54:20 PDT 2008
"Tomasz Sowiñski" <tomeksowi at gmail.com> wrote in message
news:g2h5f2$1jnq$1 at digitalmars.com...
> Robert Fraser Wrote:
>> The "module" keyword is used to assign a name to your module (which
>> incidentally must coincide with its filename & folder structure) while
>> "import" gives you access to the module with the given name.
> By the way, why do you have to repeat the filename in the file itself? I'm
> sure there must be some reason, but I can't see it now.
I think it might have to do with making it possible to make D work on
filesystems where there is no concept of "directories", such as a
database-oriented FS. In such a filesystem, there might not be any way to
identify a module other than by doing so inside the module. `select
contains(*, "module foo.bar;") from files where extension = "d"`. Though
even that wouldn't necessarily work since you'd really have to parse the
module since it could be written "module foo . bar
But in that case, why is the module declaration optional?
It's kind of confusing and to be honest, I'm not sure what purpose the
module declaration holds. It would be far more efficient in a DB-oriented
FS to instead follow some naming convention for modules, allowing you to
select them without looking at their contents.
...now I want to remove module declarations from MiniD :)
More information about the Digitalmars-d-learn