Welcome to Web-News
A Web-based News Reader
Subject Re: Functions with package protection
From Frank Benoit <keinfarbton@googlemail.com>
Date Fri, 20 Jun 2008 18:06:26 +0200
Newsgroups digitalmars.D

Jacob Carlborg schrieb:
> In the D documentation at http://www.digitalmars.com/d/1.0/function.html
> it says the following: "All non-static non-private non-template member
> functions are virtual", but this seems not to be the case. What I've
> heard and as the following example shows functions declared as package
> are non-virtual.
>
> module main;
>
> import tango.io.Stdout;
>
> class A
> {
>     package void foo ()
>     {
>         Stdout("A").newline;
>     }
> }
>
> class B : A
> {
>     package void foo ()
>     {
>         Stdout("B").newline;
>     }
> }
>
> void main ()
> {
>     A a = new B;
>     a.foo;
> }
>
> This will print "A", but according to the documentation package is
> virtual and therefore this should print "B" but doesn't. Either the
> documentation is wrong or the compiler.
>
> Compiled with GDC on OSX, I think it will give the same result with dmd
> also.

Unfortunately on
http://www.digitalmars.com/d/1.0/attribute.html#ProtectionAttribute
it is said:
"Package extends private so that package members can be accessed from
code in other modules that are in the same package. This applies to the
innermost package only, if a module is in nested packages."

Recent messages in this thread
 
-# Functions with package protection Jacob Carlborg 20-Jun-2008 12:00 pm
.-# Re: Functions with package protection (Current message) Frank Benoit 20-Jun-2008 12:06 pm
..\# Re: Functions with package protection Jacob Carlborg 21-Jun-2008 09:47 am