digitalmars.D - D and file names
- Russel Winder (11/11) Mar 25 2011 It appears that DMD barfs on files with - in the file name. Why?
- Vladimir Panteleev (10/11) Mar 25 2011 Do you mean, why doesn't DMD try to work around the problem automaticall...
- Russel Winder (18/28) Mar 25 2011 =20
- Vladimir Panteleev (11/16) Mar 25 2011 Lacking a module declaration as is your case, what would the
- Steven Schveighoffer (20/37) Mar 25 2011 Every character except '/' is valid in a file name. In D, the module na...
- Walter Bright (8/15) Mar 25 2011 The compiler synthesizes the module name from the file name. If the file...
It appears that DMD barfs on files with - in the file name. Why? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Mar 25 2011
On Fri, 25 Mar 2011 13:05:39 +0200, Russel Winder <russel russel.org.uk> wrote:It appears that DMD barfs on files with - in the file name. Why?Do you mean, why doesn't DMD try to work around the problem automatically (e.g. by substituting/removing invalid characters in the module identifier)? The error message answers your verbatim question. "test-file-name.d: Error: module test-file-name has non-identifier characters in filename, use module declaration instead" -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Mar 25 2011
On Fri, 2011-03-25 at 13:10 +0200, Vladimir Panteleev wrote:On Fri, 25 Mar 2011 13:05:39 +0200, Russel Winder <russel russel.org.uk> ==20wrote: =20=20It appears that DMD barfs on files with - in the file name. Why?=20 Do you mean, why doesn't DMD try to work around the problem automatically=(e.g. by substituting/removing invalid characters in the module =20 identifier)? The error message answers your verbatim question.- is a perfectly valid character in a file name, well on Posix compliant systems anyway. The question is why D, aping Java, imposes restrictions when there is no need."test-file-name.d: Error: module test-file-name has non-identifier =20 characters in filename, use module declaration instead"The real irritant for me is that the file in question has one function, main, there is nothing to do with modules going on here. --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel russel.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Mar 25 2011
On Fri, 25 Mar 2011 13:27:10 +0200, Russel Winder <russel russel.org.uk> wrote:- is a perfectly valid character in a file name, well on Posix compliant systems anyway. The question is why D, aping Java, imposes restrictions when there is no need.Lacking a module declaration as is your case, what would the auto-generated module name be? I'd reckon it'd be pretty much always not what the programmer expected. Allowing symbols like - in module names would complicate parsing, I'd imagine.The real irritant for me is that the file in question has one function, main, there is nothing to do with modules going on here.The compiler doesn't know that that module will never be imported by anything. What's the problem with adding a module declaration? -- Best regards, Vladimir mailto:vladimir thecybershadow.net
Mar 25 2011
On Fri, 25 Mar 2011 07:27:10 -0400, Russel Winder <russel russel.org.uk> wrote:On Fri, 2011-03-25 at 13:10 +0200, Vladimir Panteleev wrote:Every character except '/' is valid in a file name. In D, the module name must be a valid symbol, and also the name of the file you import to get that module. It's as simple as "don't name your files with non-valid symbol characters." It's the way the language is designed, and if that's too much of a burden, then don't use the language.On Fri, 25 Mar 2011 13:05:39 +0200, Russel Winder <russel russel.org.uk> wrote:- is a perfectly valid character in a file name, well on Posix compliant systems anyway. The question is why D, aping Java, imposes restrictions when there is no need.It appears that DMD barfs on files with - in the file name. Why?Do you mean, why doesn't DMD try to work around the problem automatically (e.g. by substituting/removing invalid characters in the module identifier)? The error message answers your verbatim question.Every compiled d file is a module, the compiler uses the file name if you don't provide one. Note it is not advisable to name your modules differently than the file name, because the module name is also used to import the file. This means, if you named a file differently from a module, importing the module will fail to find it. However, standalone single-file programs should not be an issue. This should compile: test-file-name.d: module testfilename; void main() {} -Steve"test-file-name.d: Error: module test-file-name has non-identifier characters in filename, use module declaration instead"The real irritant for me is that the file in question has one function, main, there is nothing to do with modules going on here.
Mar 25 2011
On 3/25/2011 4:10 AM, Vladimir Panteleev wrote:On Fri, 25 Mar 2011 13:05:39 +0200, Russel Winder <russel russel.org.uk> wrote:The compiler synthesizes the module name from the file name. If the file name has non-valid module identifiery characters in it, it can't do that. Hence the error message. The solution is to either use a module declaration to set the module name, or rename the file to be a valid module identifier. The filename=modulename and directory=packagename equivalence allows for the compiler to simply find and load imported modules. Without it you'd need some complex database to map the module names to files.It appears that DMD barfs on files with - in the file name. Why?Do you mean, why doesn't DMD try to work around the problem automatically (e.g. by substituting/removing invalid characters in the module identifier)? The error message answers your verbatim question. "test-file-name.d: Error: module test-file-name has non-identifier characters in filename, use module declaration instead"
Mar 25 2011