What is the FreeBSD situation?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Nov 4 08:46:37 UTC 2017


On Saturday, November 04, 2017 08:38:58 codephantom via Digitalmars-d wrote:
> On Saturday, 4 November 2017 at 08:17:44 UTC, Jonathan M Davis
>
> wrote:
> > Per the spec, if you don't give a module declaration, the name
> > of the module is the name of the file (minus the extension).
> > So, if you just give a module name (which you generally would
> > in any real program rather than a quick test program), then
> > it's not a problem - unless you give the module a name which
> > conflicts with something that you're trying to use.
>
> Thanks. I had actually read that spec, but forgot all about it.
>
> Having only used D for a month or so, I'm only writing snippets
> (107 so far), not actual programs.
>
> I actually had to edit the source code of my editor, so that when
> I create/save a .d file, if I happen to use hypens, then my
> editor will now automatically replace them with underscores
> (again, just because the way D deals with files).
>
> I think I'll do some more editing, and have my editor insert a
> default module name as well.
>
> Still, I don't like the spec. I would prefer that dmd did not
> implictly do stuff like that. Then I could regain the freedom to
> name my files however I wanted.

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



More information about the Digitalmars-d mailing list