Name of files causes error. Why?

Xan xancorreu at gmail.com
Fri Apr 13 11:20:50 PDT 2012


On Friday, 13 April 2012 at 04:16:52 UTC, Jesse Phillips wrote:
> On Wednesday, 11 April 2012 at 19:33:58 UTC, Xan wrote:
>> Hi,
>>
>> With helloworld program named with score or underscore, I 
>> receive the following __annoying__ error:
>>
>> $ gdmd-4.6 hola-temp.d
>> hola-temp.d: Error: module hola-temp has non-identifier 
>> characters in filename, use module declaration instead
>>
>> Why?
>> Can someone fix it. It's really annoying
>>
>> Thanks in advance,
>> Xan.
>
> Module names are used for import statements:
>
> import mymodule;
>
> As this is D code, it must have a valid identifier so that it
> parses
>
> import my-module;
>
> This could probably be special cased, but you can use these 
> names
> in code
>
> auto a = my-module.foo();
>
> Are you subtracting 'my' from 'module.foo()?'
>
> You can name you files whatever you want. Just include your
> module name at the top (recommended anyway)
>
> module my_module;
>
> In this case, if you module file is named my-module, then rdmd
> and other build tools that use your import information will be
> unable to locate my_module.d because that file does not exist.

Thanks, Jesse, for your deep explanation. Now I understant: it's 
for not confusing with minus

Thanks,
Xan.



More information about the Digitalmars-d-learn mailing list