Thread overview
Polymorphism broken by 'package' visibility
May 20, 2005
Kris
May 20, 2005
Thomas Kuehne
May 20, 2005
Walter
May 20, 2005
Kris
May 21, 2005
Ant
May 21, 2005
kris
May 23, 2005
Charlie
May 21, 2005
Thomas Kühne
May 20, 2005
class Base
{
        package char[] name ()
        {
                return "base";
        }

        char[] test ()
        {
                return name();
        }
}

class Derived : Base
{
        package override char[] name()
        {
                return "derived";
        }
}

void main()
{
        Derived d = new Derived;

        // fails!
        assert (d.test() == "derived");
}


Derived.test() returns "base" instead of "derived" ... works as expected
with 'protected' etc.


May 20, 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kris schrieb am Thu, 19 May 2005 17:21:59 -0700:
> class Base
> {
>         package char[] name ()
>         {
>                 return "base";
>         }
>
>         char[] test ()
>         {
>                 return name();
>         }
> }
>
> class Derived : Base
> {
>         package override char[] name()
>         {
>                 return "derived";
>         }
> }
>
> void main()
> {
>         Derived d = new Derived;
>
>         // fails!
>         assert (d.test() == "derived");
> }
>
>
> Derived.test() returns "base" instead of "derived" ... works as expected
> with 'protected' etc.

Added to DStress as http://dstress.kuehne.cn/run/o/overload_23.d http://dstress.kuehne.cn/run/o/overload_24.d

Thomas


-----BEGIN PGP SIGNATURE-----

iD8DBQFCjdI33w+/yD4P9tIRAlZRAJoDgHjplaFgdrcS2hl+Im4d8aq/xQCeL/i2
hyLWrLWVSuOUmtplg0qhR0M=
=Lxge
-----END PGP SIGNATURE-----
May 20, 2005
"Kris" <fu@bar.com> wrote in message news:d6jaj8$2r1n$1@digitaldaemon.com...
> Derived.test() returns "base" instead of "derived" ... works as expected
> with 'protected' etc.

This is as designed - 'private' and 'package' functions are not virtual.


May 20, 2005
Thanks for the clarification.

Private, sure. Package? That's a tad unexpected. I guess I must have missed that in the documentation?



"Walter" <newshound@digitalmars.com> wrote in message news:d6lgva$1kd0$1@digitaldaemon.com...
>
> "Kris" <fu@bar.com> wrote in message
news:d6jaj8$2r1n$1@digitaldaemon.com...
> > Derived.test() returns "base" instead of "derived" ... works as expected
> > with 'protected' etc.
>
> This is as designed - 'private' and 'package' functions are not virtual.
>
>


May 21, 2005
Kris wrote:
> Thanks for the clarification.
> 
> Private, sure. Package? That's a tad unexpected.

what happened Kris?
lost your fire? ;)

It's absurd! :(

well, not as bad as:
- default on switch (even Walter was caught on this I'm surprised nobody referred it)
- missing return
- == null
- legacy "compatibilities" (case, ~this(), cast...)
- stupid name resolution rules
- ...

:p

See Walter? D is so good that we even put up with these things!
but somehow I always feel like "almost there..." :(

Ant

PS Kris, we are all expecting a 4 pages PDF...
May 21, 2005
Ant wrote:
> Kris wrote:
> 
>> Thanks for the clarification.
>>
>> Private, sure. Package? That's a tad unexpected.
> 

Hello, Ant ~ Long time!

> what happened Kris?
> lost your fire? ;)
Hell, no. I was just waiting for you <g>

> 
> It's absurd! :(
I'd really like to hear why it /should/ be like it is ... anyone?

<snip>

> PS Kris, we are all expecting a 4 pages PDF...
Better things to do; such as teaching this octopus to waltz, on just two legs :)
May 21, 2005
Walter wrote:
| "Kris" <fu@bar.com> wrote in message
| news:d6jaj8$2r1n$1@digitaldaemon.com...
|
|> Derived.test() returns "base" instead of "derived" ... works as
|> expected with 'protected' etc.
|
|
| This is as designed - 'private' and 'package' functions are not
| virtual.
|

http://digitalmars.com/d/function.html
All non-static non-private member functions are virtual.

Thomas
May 23, 2005
lol

"Ant" <duitoolkit@yahoo.ca> wrote in message news:d6mj4f$2bdp$1@digitaldaemon.com...
> Kris wrote:
> > Thanks for the clarification.
> >
> > Private, sure. Package? That's a tad unexpected.
>
> what happened Kris?
> lost your fire? ;)
>
> It's absurd! :(
>
> well, not as bad as:
> - default on switch (even Walter was caught on this I'm surprised nobody
referred it)
> - missing return
> - == null
> - legacy "compatibilities" (case, ~this(), cast...)
> - stupid name resolution rules
> - ...
>
> :p
>
> See Walter? D is so good that we even put up with these things! but somehow I always feel like "almost there..." :(
>
> Ant
>
> PS Kris, we are all expecting a 4 pages PDF...