What is the FreeBSD situation?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Nov 4 10:05:15 UTC 2017


On Saturday, November 04, 2017 09:34:05 codephantom via Digitalmars-d wrote:
> On Saturday, 4 November 2017 at 08:46:37 UTC, Jonathan M Davis
>
> wrote:
> > Well, the modules need names. So, either, the compiler is going
> > to have to pick a name for you, or you're going to have to give
> > it one. In general though, D was designed with the idea that
> > modules would match files and packages would match directories
> > - and that the names on disk would match the ones in the file.
> > Overall, things are much simpler that way. On some level, you
> > can get around that by giving module names that don't match the
> > file names, but in general, you're just begging for trouble if
> > you don't make your file names and module names match (at least
> > some stuff is going to be looking for modules by looking at the
> > file system for them with the assumption that the package names
> > match folders and the module names match files). So, in the
> > long run, you'll just have fewer problems if you make your file
> > names and module names match.
> >
> > - Jonathan M Davis
>
> Yes. All that makes complete sense I guess.
>
> It might also make sense, that if a source code file does not
> contain a module statement, then it should not be treated as a
> module, and the compiler should look to the import statements
> instead of implicitly making in a module.

The language has no concept of any D code not being in a module. Not only
would adding such a concept complicate things, but it wouldn't help real
world programs. Having the module name infered from the file name was a
simple solution to the problem and usually doesn't cause problems (at least
as long as you're just dealing with toy programs).

Personally, I think that we would have been better off just requiring the
module statements (especially since it doesn't work to have modules in
packages without the module statements), but I doubt that that change would
be accepted at this point, particularly since it wouldn't matter for much
other than toy programs. Mostly all it would do is force folks to use module
statements up front when learning the language instead of trying to go
without like some do and then inevitably hitting issues when they start to
use packages. And that has value, but I doubt that it would be enough of an
argument to get such a change made.

- Jonathan M Davis



More information about the Digitalmars-d mailing list