Thread overview
bug in package-attribute in interfaces
Jul 17, 2007
Extrawurst
Jul 17, 2007
Extrawurst
Jul 18, 2007
Bruno Medeiros
Jul 18, 2007
Bruno Medeiros
July 17, 2007
is this possibly a bug in dmd ?

[CODE FILE "test/inter.d"]
module test.inter;

interface IFoo {
   package void bar();
}

class Foo:IFoo {
   package void bar() {
   }
}

[CODE FILE "test/testMe.d"]
module test.testMe;

import test.inter;

class Test {
   IFoo    member;
   this() {
       member = new Foo();
   }
     void bla() {
       member.bar();
   }
}

[CODE FILE "main.d"]
module main;

import test.testMe;

void main(){
   Test test = new Test();

   test.bla();
}

Gives linker error:
test\testMe.obj(testMe)
Error 42: Symbol Undefined _D4test5inter4IFoo3barMFZv

why is this?
July 17, 2007
"Extrawurst" <spam@extrawurst.org> wrote in message news:f7i0b0$25d6$1@digitalmars.com...
>
> Gives linker error:
> test\testMe.obj(testMe)
> Error 42: Symbol Undefined _D4test5inter4IFoo3barMFZv
>
> why is this?

Don't quote me on this but I think I heard that 'package' methods are oddly non-virtual.  Try removing the 'package' attribute from the interface/class methods.


July 17, 2007
removing package works as expected, but it was exactly the "package" attribute i need in this situation ;-(


Jarrett Billingsley schrieb:
> "Extrawurst" <spam@extrawurst.org> wrote in message news:f7i0b0$25d6$1@digitalmars.com...
>   
>> Gives linker error:
>> test\testMe.obj(testMe)
>> Error 42: Symbol Undefined _D4test5inter4IFoo3barMFZv
>>
>> why is this?
>>     
>
> Don't quote me on this but I think I heard that 'package' methods are oddly non-virtual.  Try removing the 'package' attribute from the interface/class methods. 
>
>
>   
July 17, 2007
"Extrawurst" <spam@extrawurst.org> wrote in message news:f7jbaa$1ouh$1@digitalmars.com...
> removing package works as expected, but it was exactly the "package" attribute i need in this situation ;-(
>

'package' has never been given much attention, sadly.  The thing is that 'package' is an entirely different animal from 'public', 'private', and 'protected', but D doesn't seem to treat it as such.  'package' controls visibility between modules; it shouldn't have any effect on whether a method is virtual or nonvirtual.

(Yes, this has been discussed before, probably for at least two years, if not longer.  Nothing has ever been addressed.)


July 18, 2007
Extrawurst wrote:
> removing package works as expected, but it was exactly the "package" attribute i need in this situation ;-(
> 
> 
> Jarrett Billingsley schrieb:
>> "Extrawurst" <spam@extrawurst.org> wrote in message news:f7i0b0$25d6$1@digitalmars.com...
>>  
>>> Gives linker error:
>>> test\testMe.obj(testMe)
>>> Error 42: Symbol Undefined _D4test5inter4IFoo3barMFZv
>>>
>>> why is this?
>>>     
>>
>> Don't quote me on this but I think I heard that 'package' methods are oddly non-virtual.  Try removing the 'package' attribute from the interface/class methods.
>>
>>   

It is said that interface methods should all be public, since doing otherwise kinda goes against the purpose of an interface (which is to expose an inteface :P).
Try making the interface itself package, instead of the interface's methods.


-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
July 18, 2007
Bruno Medeiros wrote:
> Extrawurst wrote:
>> removing package works as expected, but it was exactly the "package" attribute i need in this situation ;-(
>>
>>
>> Jarrett Billingsley schrieb:
>>> "Extrawurst" <spam@extrawurst.org> wrote in message news:f7i0b0$25d6$1@digitalmars.com...
>>>  
>>>> Gives linker error:
>>>> test\testMe.obj(testMe)
>>>> Error 42: Symbol Undefined _D4test5inter4IFoo3barMFZv
>>>>
>>>> why is this?
>>>>     
>>>
>>> Don't quote me on this but I think I heard that 'package' methods are oddly non-virtual.  Try removing the 'package' attribute from the interface/class methods.
>>>
>>>   
> 
> It is said that interface methods should all be public, since doing otherwise kinda goes against the purpose of an interface (which is to expose an inteface :P).
> Try making the interface itself package, instead of the interface's methods.
> 
> 

Hum, I forgot: that's how it *should* work, but D currently doesn't honor protection attributes for types(classes, interfaces, etc.), only for variables and functions.

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D