What is the FreeBSD situation?

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


On Saturday, November 04, 2017 08:02:38 codephantom via Digitalmars-d wrote:
> On Saturday, 4 November 2017 at 03:19:00 UTC, Jonathan M Davis
>
> wrote:
> > So, that implies that you're doing something funny, but if
> > you're installing dmd with an installer or package manager,
> > then I would think that it would at least be set up correctly.
>
> ok. I worked it out.
>
> my file was named: to.d
>
> so that caused dmd some confusion it seems.
>
> change the name to something else, then dmd is ok with that code.
>
> There's some real 'gotchas' when it comes to file names and
> dmd... I'm not sure I like it.
>
> Interestingly, gdc didn't care that my file was named to.d, it
> did what I wanted the code to do. Would like dmd to do the same
> ;-)
>
> But ldc does the same thing as dmd...neither likes a file named
> to.d when you're calling a template with the same name.

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. If you'd had

module to;

at the top of the module, then you'd have the same problem regardless of the
file name. The module name wins out over the imported name when there's a
conflict, because the module name is a local symbol. In practice, that's
rarely a problem, though poor module-naming practices could certainly make
it a problem.

You can also work around it by using the fully qualified name (std.conv.to
in this case) or by aliasing the symbol to a new name (I think that you can
also statically import a symbol with a new name, but if so, that's basically
the same as statically importing it and then aliasing it).

If gdc doesn't have the same behavior, it's either a bug, and/or it's
related to the fact that the last released version of gdc matched dmd 2.068
(IIRC). So, right now, gdc is a terrible compiler to use unless you don't
care about using a really old version of D. I think that they're getting
close to releasing an update that's much closer to the current version of
dmd, but IIUC, the switch of the frontend from C++ to D was a huge roadblock
for them, since they had a lot of redesign work to do (they also don't have
much manpower). So, it's taken them quite a while to get back up-to-date.

- Jonathan M Davis



More information about the Digitalmars-d mailing list