www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Problems with minTL with DMD 0.120 and various other issues

reply "Maxime Larose" <mlarose broadsoft.com> writes:
Trying to compile MinTL with DMD 0.120, compiler complains about bad
argument types all over... ex: with list.d it reports List not being List*,
etc.
I unfortunately don't have the verbose results here with me, but I could
easily get them if no one else has seen this.


Also, I don't know if this is a bug or not, but D seems a bit off when it
comes to handling object references vs pointers.

Ex:
struct Node(T) {
  T value;
  Node(T) next;        // this doesn't work _inside_ Node(T), although it
works fine elsewhere
                                // compiler says: Node(T) is a class...
which is exactly what I want...
}

struct Node(T) {
  T value;
  typeof(this) next;    // this works fine, but now next is a Node(T)* (a
pointer)
                               // I don't want a pointer, I want an object
reference
}

I understand that under the hood a pointer and an object reference may be
the exact same thing in D. However, this behavior is not very
object-oriented like. With the second definition, one has to code to deal
with pointers, whereas it would have been better to simply treat node.next
as an object.

The second structure definition (where next is a pointer) leads to:
node.next = new TNode(int);    // this doesn't compile.
                                                // Compiler complains about
next being a pointer, so:
node.next = &(new TNode(int));  // ugly hack

This can't be right...


With DMD 0.120:

TNode(int) node;
// node is not initialized...
// I must initialize it manually:
node = new TNode(int);
// is this normal???


I read the doc many times, but it is unclear (or I've missed it) how D deals
with these issues. This can't possibly be expected behavior. What I am
missing?
Apr 18 2005
parent reply "Ben Hinkle" <bhinkle mathworks.com> writes:
"Maxime Larose" <mlarose broadsoft.com> wrote in message 
news:d40vj6$1l94$1 digitaldaemon.com...
 Trying to compile MinTL with DMD 0.120, compiler complains about bad
 argument types all over... ex: with list.d it reports List not being 
 List*,
 etc.
 I unfortunately don't have the verbose results here with me, but I could
 easily get them if no one else has seen this.

MinTL is badly busted in dmd-120 and 121. I don't have a work-around (aside from using 119). I ping'ed Walter about the bug so I'm hoping he can fix things up for 122.
 Also, I don't know if this is a bug or not, but D seems a bit off when it
 comes to handling object references vs pointers.

 Ex:
 struct Node(T) {
  T value;
  Node(T) next;        // this doesn't work _inside_ Node(T), although it
 works fine elsewhere
                                // compiler says: Node(T) is a class...
 which is exactly what I want...
 }

 struct Node(T) {
  T value;
  typeof(this) next;    // this works fine, but now next is a Node(T)* (a
 pointer)
                               // I don't want a pointer, I want an object
 reference
 }

Inside of a struct S "this" has type S*.
 I understand that under the hood a pointer and an object reference may be
 the exact same thing in D. However, this behavior is not very
 object-oriented like. With the second definition, one has to code to deal
 with pointers, whereas it would have been better to simply treat node.next
 as an object.

A pointer to a struct and a reference to a class instance are very different in D and you can't cast one to the other.
 The second structure definition (where next is a pointer) leads to:
 node.next = new TNode(int);    // this doesn't compile.
                                                // Compiler complains about
 next being a pointer, so:
 node.next = &(new TNode(int));  // ugly hack

 This can't be right...

That does seem wierd. the "new" should return a pointer to a TNode!(int)
 With DMD 0.120:

 TNode(int) node;
 // node is not initialized...
 // I must initialize it manually:
 node = new TNode(int);
 // is this normal???

Is TNode a struct or class? I can't tell from the snippets of code what you actually compiled to get the behavior above. If TNode!(int) is a struct then the statements "TNode!(int) node; node = new TNode!(int);" should be illegal..
 I read the doc many times, but it is unclear (or I've missed it) how D 
 deals
 with these issues. This can't possibly be expected behavior. What I am
 missing?

Complete code examples would help (at least they'd help me).
Apr 18 2005
parent reply "Maxime Larose" <mlarose broadsoft.com> writes:
At least, I know that minTL compilation problems weren't me. Glad I didn't
spend too much time investigating... (the errors looked fishy - seemed to be
a compiler thing). Does this happen often? (A new version of the compiler
that doesn't compile previously compiling code)

About the other stuff, I mixed class and struct. I think I did the tests
with both and both had the same results, but now I'm not sure anymore... You
right, I'll get complete code examples. (Don't have them available where I
am right now...)

Thanks,

Max




"Ben Hinkle" <bhinkle mathworks.com> wrote in message
news:d4114r$1nbv$1 digitaldaemon.com...
 "Maxime Larose" <mlarose broadsoft.com> wrote in message
 news:d40vj6$1l94$1 digitaldaemon.com...
 Trying to compile MinTL with DMD 0.120, compiler complains about bad
 argument types all over... ex: with list.d it reports List not being
 List*,
 etc.
 I unfortunately don't have the verbose results here with me, but I could
 easily get them if no one else has seen this.

MinTL is badly busted in dmd-120 and 121. I don't have a work-around

 from using 119). I ping'ed Walter about the bug so I'm hoping he can fix
 things up for 122.

 Also, I don't know if this is a bug or not, but D seems a bit off when


 comes to handling object references vs pointers.

 Ex:
 struct Node(T) {
  T value;
  Node(T) next;        // this doesn't work _inside_ Node(T), although it
 works fine elsewhere
                                // compiler says: Node(T) is a class...
 which is exactly what I want...
 }

 struct Node(T) {
  T value;
  typeof(this) next;    // this works fine, but now next is a Node(T)* (a
 pointer)
                               // I don't want a pointer, I want an


 reference
 }

Inside of a struct S "this" has type S*.
 I understand that under the hood a pointer and an object reference may


 the exact same thing in D. However, this behavior is not very
 object-oriented like. With the second definition, one has to code to


 with pointers, whereas it would have been better to simply treat


 as an object.

A pointer to a struct and a reference to a class instance are very

 in D and you can't cast one to the other.

 The second structure definition (where next is a pointer) leads to:
 node.next = new TNode(int);    // this doesn't compile.
                                                // Compiler complains


 next being a pointer, so:
 node.next = &(new TNode(int));  // ugly hack

 This can't be right...

That does seem wierd. the "new" should return a pointer to a TNode!(int)
 With DMD 0.120:

 TNode(int) node;
 // node is not initialized...
 // I must initialize it manually:
 node = new TNode(int);
 // is this normal???

Is TNode a struct or class? I can't tell from the snippets of code what

 actually compiled to get the behavior above. If TNode!(int) is a struct

 the statements "TNode!(int) node; node = new TNode!(int);" should be
 illegal..

 I read the doc many times, but it is unclear (or I've missed it) how D
 deals
 with these issues. This can't possibly be expected behavior. What I am
 missing?

Complete code examples would help (at least they'd help me).

Apr 18 2005
parent "Ben Hinkle" <bhinkle mathworks.com> writes:
"Maxime Larose" <mlarose broadsoft.com> wrote in message 
news:d4140h$1q62$1 digitaldaemon.com...
 At least, I know that minTL compilation problems weren't me. Glad I didn't
 spend too much time investigating... (the errors looked fishy - seemed to 
 be
 a compiler thing). Does this happen often? (A new version of the compiler
 that doesn't compile previously compiling code)

Typically new dmd release are fine wrt backwards compatibility in my experience. Every now and then one comes out that seems to tickle some sublte issues and dmd-120 was one of those releases, unfortunately.
 About the other stuff, I mixed class and struct. I think I did the tests
 with both and both had the same results, but now I'm not sure anymore... 
 You
 right, I'll get complete code examples. (Don't have them available where I
 am right now...)

no problem. You might also want to try dmd-119 just in case.
Apr 18 2005