Thread overview
[Issue 12758] allow file names with hyphens
May 18, 2014
Andrej Mitrovic
May 18, 2014
Tom Browder
May 18, 2014
Tom Browder
[Issue 12758] Compiler should infer acceptable module name when file name includes hyphens
May 18, 2014
yebblies
May 18, 2014
Tom Browder
May 18, 2014
Tom Browder
Jun 25, 2017
Vladimir Panteleev
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc

--- Comment #1 from bearophile_hugs@eml.cc ---
(In reply to Tom Browder from comment #0)
> D source file names with hyphens should be allowed, e.g., "test-bu.d".

Isn't it simpler to rename the file "test_bu.d"?

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com

--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> ---
(In reply to Tom Browder from comment #0)
> D source file names with hyphens should be allowed, e.g., "test-bu.d".

Note that module names must be valid D identifiers. So if you have "test-bu.d" it would need to have a separate module declaration (e.g. "module test_bu;"). This this also means that the compiler either has to try and use heuristics to find the file on disk, or you have to explicitly pass it to the compiler.

It's implementable, but I'm not sure if Walter would ok this.

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

--- Comment #3 from Tom Browder <tombrowder@acm.org> ---
> Isn't it simpler to rename the file "test_bu.d"?

Simpler, but I'm looking at dealing with a large C/C++ code base and many files are named using hyphens.  I know it may be easier to rename the file but I still think the capability should be there.

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

--- Comment #4 from bearophile_hugs@eml.cc ---
(In reply to Tom Browder from comment #3)

> I know it may be easier to rename the file
> but I still think the capability should be there.

I think the little convenience of not renaming those files could be less important than allowing D file names that can't be module names.

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

--- Comment #5 from Tom Browder <tombrowder@acm.org> ---
> Isn't it simpler to rename the file "test_bu.d"?

Simpler, but I'm looking at dealing with a large C/C++ code base and many files are named using hyphens.  I know it may be easier to rename the file but I still think the capability should be there.

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com
            Summary|allow file names with       |Compiler should infer
                   |hyphens                     |acceptable module name when
                   |                            |file name includes hyphens

--- Comment #6 from yebblies <yebblies@gmail.com> ---
I don't think the compiler should be guessing what you wanted the module to be called.  If you want to name your files with non-identifier characters that's fine, but you will have to use a module declaration.

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

Tom Browder <tombrowder@acm.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tombrowder@acm.org

--
May 18, 2014
https://issues.dlang.org/show_bug.cgi?id=12758

--- Comment #7 from Tom Browder <tombrowder@acm.org> ---
(In reply to yebblies from comment #6)
> I don't think the compiler should be guessing what you wanted the module to be called.  If you want to name your files with non-identifier characters that's fine, but you will have to use a module declaration.

I respectfully disagree.  The default for dmd should be to translate a legitimate file name into a legitimate module name, and give a warning at some error level.

--
June 25, 2017
https://issues.dlang.org/show_bug.cgi?id=12758

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net
         Resolution|---                         |WONTFIX

--- Comment #8 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to yebblies from comment #6)
> I don't think the compiler should be guessing what you wanted the module to be called.

Indeed. It is by the same reasoning that the compiler will not do case-insensitive lookup (on case-sensitive filesystems). Not only is this less efficient (enumerating a directory can be much more inefficient than accessing a file by its file name), but it creates problems such as multiple file names mapping to the same module name (what if you have a-b.d and a_b.d in the same directory?).

--