digitalmars.D - Unexpected restriction of file names ???
- Georg Wrede (17/17) Nov 09 2005 I have the following file, called foo-bar.d:
- Jarrett Billingsley (8/25) Nov 09 2005 It makes sense if you think about it. If you don't have a module
- J C Calvarese (13/30) Nov 09 2005 I think it's already covered in the docs, but perhaps it should be clear...
- Georg Wrede (2/36) Nov 09 2005 Exactly.
I have the following file, called foo-bar.d: void main(){} Trying to compile this gives the following error message: $dmd foo-bar.d foo-bar.d: module foo-bar has non-identifier characters in filename, use module declaration instead I fear this is on purpose, so I didn't post on Bugs. But this is unexpected behavior from a compiler. -------------------- Doing my homework while writing this, I found out that the following change does away with the problem: module foobar; void main(){} Now "dmd foo-bar.d" compiles ok. -------------------- This should at least get more prominent in the docs, and if there ever will be a faq, this should be there too.
Nov 09 2005
"Georg Wrede" <georg.wrede nospam.org> wrote in message news:4371B4D9.5000907 nospam.org...I have the following file, called foo-bar.d: void main(){} Trying to compile this gives the following error message: $dmd foo-bar.d foo-bar.d: module foo-bar has non-identifier characters in filename, use module declaration instead I fear this is on purpose, so I didn't post on Bugs. But this is unexpected behavior from a compiler. -------------------- Doing my homework while writing this, I found out that the following change does away with the problem: module foobar; void main(){} Now "dmd foo-bar.d" compiles ok. -------------------- This should at least get more prominent in the docs, and if there ever will be a faq, this should be there too.It makes sense if you think about it. If you don't have a module declaration, it takes the name from the filename; since "foo-bar" is an illegal identifier, it doesn't compile. Module identifiers have the same naming restrictions as any other entity in D; begin with an alpha or underscore, and then alphanum or underscore for the rest. Just curious, what would you like it to do instead?
Nov 09 2005
In article <4371B4D9.5000907 nospam.org>, Georg Wrede says...I have the following file, called foo-bar.d: void main(){} Trying to compile this gives the following error message: $dmd foo-bar.d foo-bar.d: module foo-bar has non-identifier characters in filename, use module declaration instead I fear this is on purpose, so I didn't post on Bugs. But this is unexpected behavior from a compiler. -------------------- Doing my homework while writing this, I found out that the following change does away with the problem: module foobar; void main(){} Now "dmd foo-bar.d" compiles ok. -------------------- This should at least get more prominent in the docs, and if there ever will be a faq, this should be there too.I think it's already covered in the docs, but perhaps it should be clearer. From http://www.digitalmars.com/d/module.html: Modules have a one-to-one correspondence with source files. The module name is the file name with the path and extension stripped off. Modules automatically provide a namespace scope for their contents. Modules superficially resemble classes, but differ in that: .. Module Declaration The ModuleDeclaration sets the name of the module and what package it belongs to. If absent, the module name is taken to be the same name (stripped of path and extension) of the source file name. jcc7
Nov 09 2005
J C Calvarese wrote:In article <4371B4D9.5000907 nospam.org>, Georg Wrede says...Exactly.I have the following file, called foo-bar.d: void main(){} Trying to compile this gives the following error message: $dmd foo-bar.d foo-bar.d: module foo-bar has non-identifier characters in filename, use module declaration instead I fear this is on purpose, so I didn't post on Bugs. But this is unexpected behavior from a compiler. -------------------- Doing my homework while writing this, I found out that the following change does away with the problem: module foobar; void main(){} Now "dmd foo-bar.d" compiles ok. -------------------- This should at least get more prominent in the docs, and if there ever will be a faq, this should be there too.I think it's already covered in the docs, but perhaps it should be clearer.
Nov 09 2005