Does the 'package' protection attribute not work?
Jonathan M Davis
jmdavisProg at gmx.com
Sun Aug 7 14:18:55 PDT 2011
On Sunday 07 August 2011 18:58:53 Stijn Herreman wrote:
> module main;
>
> import std.stdio;
> import my_module;
>
> int main()
> {
> my_method();
> return 0;
> }
>
>
> module my_module;
>
> import std.stdio;
>
> package void my_method()
> {
> writeln("Hello D-World!");
> }
>
>
> Error: function my_module.my_method is not accessible from main
Hmmm. My guess would be that either it's a bug or that from D's perspective,
neither of your modules are in a package. They have no package in front of
their names; they're at the base level of the hierarchy. And that might mean
that they don't have a package, so they don't share a package. But I don't
know.
Personally, I don't see much point in using the package specifier when you're
not actually using a package hierarchy (you're just making it so that
everything but stuff which actually uses a hierarchy can use the function - it
would be a really weird distinction to make). So, it wouldn't entirely
surprise me if this is completely by design. It might be a bug though.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list