Thread overview
Bug: help me!
Nov 28, 2004
Sjoerd van Leent
Re: Bug: help me! - YES it's a BUG
Nov 29, 2004
Ant
Nov 29, 2004
Simon Buchan
Nov 29, 2004
Ant
Nov 29, 2004
Simon Buchan
Nov 29, 2004
Ant
Nov 29, 2004
Sjoerd van Leent
November 28, 2004
I am not sure if this a dmd bug or if I am bugging...
The following code gives "Access Violation" and I don't unserstand why.
If I remove the "void bugMethod()" in interface ITest the code works.
If I change ITest to an abstract class with an "abstract void bugMethod()"
the code works too.

Can someone explain me...thanks!

interface ITest {
    void bugMethod();
}

class Test : ITest {
    private IManager _manager;

     public this(IManager manager) {
        _manager = manager;
        _manager.register(this);
    }
    public void bugMethod() {

    }
}

interface IManager {
    void register(ITest itest);
}

class TestManager : IManager {
    private ITest[ITest] _aa;

    public this() {
        new Test(this);
        new Test(this);
    }

    public void register(ITest i) {
        _aa[i] = i;
    }
}

-- 
Miguel Ferreira Simoes


November 28, 2004
Not quite a bug. It has to do with the list you are using. You're trying to have a map with self references, this isn't working.

The following code is working as expected (though the register function is different now):

interface ITest {
    void bugMethod();
}

class Test : ITest {
    private IManager _manager;

    public this(IManager manager) {
        _manager = manager;
        _manager.register(this);
    }
    public void bugMethod() {

    }
}

interface IManager {
    uint register(ITest itest);
}

class TestManager : IManager {
    private ITest[ulong] _aa;

    public this() {
        new Test(this);
        //new Test(this);
    }

    public uint register(ITest i)
        static ulong registerInstance;
        _aa[registerInstance] = i;
	++registerInstance;
        return registerInstance - 1;
    }
}

int main(char[][] args) {
	new TestManager();
	return 0;
}

Regards,
Sjoerd

Miguel Ferreira Simões wrote:
> I am not sure if this a dmd bug or if I am bugging...
> The following code gives "Access Violation" and I don't unserstand why.
> If I remove the "void bugMethod()" in interface ITest the code works.
> If I change ITest to an abstract class with an "abstract void bugMethod()" the code works too.
> 
> Can someone explain me...thanks!
> 
> ...
> 
November 28, 2004
Thanks!

You said that it's not a bug and that self-referencing maps aren't working. But should they work? If so, imho, it seems a bug. Do you know why it works with abstract classes (instead of interfaces)?


November 29, 2004
On Mon, 29 Nov 2004 00:13:57 +0100, Sjoerd van Leent wrote:

> Not quite a bug. It has to do with the list you are using. You're trying to have a map with self references, this isn't working.

I don't like that explanation!

this works:
############
class NewClass
{
	this()
	{
		printf("NewClass");
	}
}

void main()
{
	//new TestManager();
	NewClass[NewClass] nn;

	NewClass a = new NewClass();
	nn[a] = a;

}
#############

Did I not understant what you're saying?
and Miguel says it work's if the interface doesn't define one of the
methods...

I think this is a bug.

BTW this type of construct where you use "this" on the
constructor is illegal on java (I think...)

Ant

November 29, 2004
On Sun, 28 Nov 2004 19:11:45 -0500, Ant <duitoolkit@yahoo.ca> wrote:

> On Mon, 29 Nov 2004 00:13:57 +0100, Sjoerd van Leent wrote:
>
>> Not quite a bug. It has to do with the list you are using. You're trying
>> to have a map with self references, this isn't working.
>
> I don't like that explanation!
>
> this works:
> ############
> class NewClass
> {
> 	this()
> 	{
> 		printf("NewClass");
> 	}
> }
>
> void main()
> {
> 	//new TestManager();
> 	NewClass[NewClass] nn;
> 	
> 	NewClass a = new NewClass();
> 	nn[a] = a;
> 	
> }
> #############
>
> Did I not understant what you're saying?
> and Miguel says it work's if the interface doesn't define one of the
> methods...
>
> I think this is a bug.
>
> BTW this type of construct where you use "this" on the
> constructor is illegal on java (I think...)
>
> Ant
>

What about D :D

T[T] should be fine... after all, we have all done dictionaries, right?
(char[][char[]] dictionary;)

Other than that... well, lets just say OO isn't ANYONE'S strong point.

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
November 29, 2004
On Mon, 29 Nov 2004 18:38:38 +1300, Simon Buchan wrote:

> On Sun, 28 Nov 2004 19:11:45 -0500, Ant <duitoolkit@yahoo.ca> wrote:
> 
> 
> What about D :D
> 
> T[T] should be fine... after all, we have all done dictionaries, right?
> (char[][char[]] dictionary;)
> 
> Other than that... well, lets just say OO isn't ANYONE'S strong point.

???

I don't get it... what are you saying?

I'm thinking I didn't understant Sjoerd van Leent explanation...

Ant

November 29, 2004
On Mon, 29 Nov 2004 00:53:07 -0500, Ant <duitoolkit@yahoo.ca> wrote:

> On Mon, 29 Nov 2004 18:38:38 +1300, Simon Buchan wrote:
>
>> On Sun, 28 Nov 2004 19:11:45 -0500, Ant <duitoolkit@yahoo.ca> wrote:
>>
>>
>> What about D :D
>>
>> T[T] should be fine... after all, we have all done dictionaries, right?
>> (char[][char[]] dictionary;)
>>
>> Other than that... well, lets just say OO isn't ANYONE'S strong point.
>
> ???
>
> I don't get it... what are you saying?
>
> I'm thinking I didn't understant Sjoerd van Leent explanation...
>
> Ant
>

Sorry... What I meant was:
What about using this in a D constructor, (as opposed to Java) is
that OK?

You are right that it is unlikely a self-typed assosiative array
would be the cause (even if the value was the key)
(BTW, is void[<sometype>] allowed as a set type? Should it be?)

Object Oriented programming is confusing to everybody, even the ppl
who write compilers and invent languages, so what chance do WE have?

Is that clearer?

I'm thinking this case has to be reduced first...

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
November 29, 2004
On Mon, 29 Nov 2004 20:24:27 +1300, Simon Buchan wrote:

> On Mon, 29 Nov 2004 00:53:07 -0500, Ant <duitoolkit@yahoo.ca> wrote:
> 
>> On Mon, 29 Nov 2004 18:38:38 +1300, Simon Buchan wrote:
>>
>>> On Sun, 28 Nov 2004 19:11:45 -0500, Ant <duitoolkit@yahoo.ca> wrote:
>>>
>>>
>>> What about D :D
>>>
>>> T[T] should be fine... after all, we have all done dictionaries, right?
>>> (char[][char[]] dictionary;)
>>>
>>> Other than that... well, lets just say OO isn't ANYONE'S strong point.
>>
>> ???
>>
>> I don't get it... what are you saying?
>>
>> I'm thinking I didn't understant Sjoerd van Leent explanation...
>>
>> Ant
>>
> 
> Sorry... What I meant was:
> What about using this in a D constructor, (as opposed to Java) is
> that OK?

it's suppose to be.
java, as usual - I guess, doesn't allow it for simplicity on
the implementation.
D, as usual, is smarter, and, as usual, buggier (it's beta after all).

what strikes me is the interface. I didn't try it but seems it works fine without the method defined on the interface. If changing the interface makes the executable valid or not then it's a bug anyway we look at it.

> 
> Object Oriented programming is confusing to everybody, even the ppl who write compilers and invent languages, so what chance do WE have?
> 
> Is that clearer?

thanks :)

> 
> I'm thinking this case has to be reduced first...

Ant

November 29, 2004
Ant wrote:
> On Mon, 29 Nov 2004 20:24:27 +1300, Simon Buchan wrote:
> 
> 
>>On Mon, 29 Nov 2004 00:53:07 -0500, Ant <duitoolkit@yahoo.ca> wrote:
>>
>>
>>>On Mon, 29 Nov 2004 18:38:38 +1300, Simon Buchan wrote:
>>>
>>>
>>>>On Sun, 28 Nov 2004 19:11:45 -0500, Ant <duitoolkit@yahoo.ca> wrote:
>>>>
>>>>
>>>>What about D :D
>>>>
>>>>T[T] should be fine... after all, we have all done dictionaries, right?
>>>>(char[][char[]] dictionary;)
>>>>
>>>>Other than that... well, lets just say OO isn't ANYONE'S strong point.
>>>
>>>???
>>>
>>>I don't get it... what are you saying?
>>>
>>>I'm thinking I didn't understant Sjoerd van Leent explanation...
>>>
>>>Ant
>>>
>>
>>Sorry... What I meant was:
>>What about using this in a D constructor, (as opposed to Java) is
>>that OK?
> 
> 
> it's suppose to be.
> java, as usual - I guess, doesn't allow it for simplicity on
> the implementation.
> D, as usual, is smarter, and, as usual, buggier (it's beta after all).
> 
> what strikes me is the interface. I didn't try it but seems
> it works fine without the method defined on the interface.
> If changing the interface makes the executable valid or not then it's a bug anyway we look at it.
> 
> 
>>Object Oriented programming is confusing to everybody, even the ppl
>>who write compilers and invent languages, so what chance do WE have?
>>
>>Is that clearer?
> 
> 
> thanks :)
> 
> 
>>I'm thinking this case has to be reduced first...
> 
> 
> Ant
> 

Allright, it is a bug (or not, it may be intented behaviour, but I don't think it is). And I didn't mean to say that self references of interfaces with a method shouldn't work, I just doesn't seem to work. As I read over the part of stating that interfaces without a method do work as expected.

This is more weird since their are more fields then only the methods specified.

My apologies for being unclear.

Regards,
Sjoerd