FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Incompatible types or compiler bug?

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
Eelco



Joined: 28 Jun 2004
Posts: 10
Location: Netherlands

PostPosted: Sun Jul 04, 2004 3:19 pm    Post subject: Incompatible types or compiler bug? Reply with quote

please have a look at this part of my matrix class:

Code:
import vector3;

struct Matrix3{

   public Vector3 x,y,z; //column vectors

    public Vector3 opMul(Vector3 v){
       Vector3 r;
       
       r.x = x.x*v.x + y.x*v.y + z.x*v.z;
       r.y = x.y*v.x + y.y*v.y + z.y*v.z;
       r.z = x.z*v.x + y.z*v.y + z.z*v.z;
       
      return r;
    }
   
    public Matrix3 opMul(Matrix3 m){
       Matrix3 r;
       
       r.x = this * m.x;
       r.y = this * m.y;
       r.z = this * m.z;
       
       return r;
    }
}


the lines 'r.x = this * m.x;' etc. wont compile: it gives an incompatible type error with some mumbo jumbo after it i dont understand. i really dont have a clue why. it just says vector = matrix * vector, which is clearly defined just that way the very method above it.

am i missing something very obvious? not that its really important, its only synthetic sugar ofcource, but id like to understandwhy D is behaving the way it does. or if its just a bug in the compiler..

thanks in advance Smile
Back to top
View user's profile Send private message
Eelco



Joined: 28 Jun 2004
Posts: 10
Location: Netherlands

PostPosted: Sun Jul 04, 2004 4:40 pm    Post subject: Reply with quote

it was answer A) i was missing the obvious.

a matter of a *, because this ofcource isnt a stack object but a pointer...

while im busy spouting my ignorance, allow me to spam these boards with another question: D doesnt have an inline keyword: the compiler is supposed to decide when to inline or not. rather annoying though that it doesnt inline things like dotproducts in inner loops... i have -inline compiler flag set. if it doesnt inline stuff like that, what in the name of god does it inline then?
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Mon Jul 05, 2004 12:20 am    Post subject: Inlining Reply with quote

Eelco wrote:
D doesnt have an inline keyword: the compiler is supposed to decide when to inline or not. rather annoying though that it doesnt inline things like dotproducts in inner loops
I hope you do realize that DMD isn't at 1.00 yet. Walter is more concerned about fixing more serious bugs than producing sub-optimal code.

I think of it like this: First it has to work, then it can work better.

If this really concerns you, you can post an example of what you think the problem is on the Bugs newsgroup.
Back to top
View user's profile Send private message AIM Address
Eelco



Joined: 28 Jun 2004
Posts: 10
Location: Netherlands

PostPosted: Mon Jul 05, 2004 3:47 am    Post subject: Re: Inlining Reply with quote

jcc7 wrote:
I think of it like this: First it has to work, then it can work better.


ofcource, ofcource.

but the annoying part is that i dont know if it isnt implemented yet or if im doing something wrong. well ill just wont use function calls at all anymore in time critical parts, no big deal since its usually only the two inner loops you have to worry about anyway.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group