Import all?

JS js.mdnq at gmail.com
Thu Jul 18 16:25:54 PDT 2013


On Thursday, 18 July 2013 at 23:14:39 UTC, Jonathan M Davis wrote:
> On Thursday, July 18, 2013 23:53:53 JS wrote:
>> On Thursday, 18 July 2013 at 19:35:15 UTC, Jonathan M Davis 
>> wrote:
>> > On Thursday, July 18, 2013 11:38:41 JS wrote:
>> >> Essentially all emulates the package.d, and I like it 
>> >> because
>> >> it's descriptive and easily maintainable... thats all I was
>> >> after
>> >> in the first place. Too bad package doesn't work properly ;/
>> > 
>> > Do you mean the package attribute or package.d? package.d
>> > should work just
>> > fine. I'm not aware of any outstanding bugs with it. The
>> > attribute is still
>> > broken though, I believe.
>> > 
>> > - Jonathan M Davis
>> 
>> When I used package.d things didn't work out like they do using
>> all. It may be due to bugs on my end(I had a few typos). Maybe 
>> I
>> will try it again though(simple rename and remove .all).
>
> Well, what you were posting was wrong, and I believe that I 
> pointed out why. A
> package.d file's module declaration needs to have the same name 
> as the package.
> So, if you have
>
> abc/foo/package.d
>
> then package.d needs
>
> module abc.foo;
>
> for its module declaration. Then you import the package as if 
> it were a
> module, so you get any public imports which were in it. But as 
> I said before,
> this won't work for the top level, because the top level isn't 
> a package. You
> need a sub-folder to have a package.
>

Yes, that is one of the things I tried.. and I'm not working from 
the top level since that is the library container folder which 
contains all the actual libraries which then contain the packages.

When I rename the all.d files to package and import the package I 
get two errors:

Error	1	Error: can only import from a module, not from package JS
Error	2	Error: module JS is in file 'JS.d' which cannot be read		


My hierarchy is

/lib/JS/package.d
module JS;
public import ....

and I import JS by using import JS;

vs using all.d

/lib/JS/All.d
module JS.All;
public import ....

and I import JS by using import JS.All;

otherwise everything is identical. .All works without issue.

Note I reverted to 2.062 because 2.063.2 was causing weird errors 
in Visual D... so this might be the problem but I remember 
getting the same errors when I was trying 2.063.2(but possibly 
not)...

In any case, I'll just stick with All for now, I think I like how 
explicit it is.




More information about the Digitalmars-d-learn mailing list