Why isn't == used to compare structs

2010-02-08 Thread Jacob Carlborg
struct String { char[] data; } void main () { auto foo = String(foo); auto bar = String(foo.dup); assert(bar == foo); } Why isn't == used to compare the struct members in the code above? I mean, if I compare the structs with == it could also use == to compare

Re: Why isn't == used to compare structs

2010-02-08 Thread Manuel König
Am Mon, 08 Feb 2010 12:19:12 +0100 schrieb Jacob Carlborg d...@me.com: struct String { char[] data; } void main () { auto foo = String(foo); auto bar = String(foo.dup); assert(bar == foo); } Why isn't == used to compare the struct members in the code

Re: Why isn't == used to compare structs

2010-02-08 Thread Trass3r
Why isn't == used to compare the struct members in the code above? I mean, if I compare the structs with == it could also use == to compare the members. If I use is to compare the structs it could use is to compare them members. Structs are compared *bitwise*! When you dup your pointer is

Re: Why isn't == used to compare structs

2010-02-08 Thread Pelle Månsson
On 02/08/2010 01:48 PM, Trass3r wrote: Why isn't == used to compare the struct members in the code above? I mean, if I compare the structs with == it could also use == to compare the members. If I use is to compare the structs it could use is to compare them members. Structs are compared

Re: Why isn't == used to compare structs

2010-02-08 Thread Trass3r
I believe the question was *why* things are this way. I think it's weird. It's common behavior. In the end structs are just a way to map a memory range to some variable tuple. If you really need == for all members you can always overload opEquals!!

Is there a way to get a list of functions that get inlined by dmd?

2010-02-08 Thread Trass3r
Would be interesting.

Re: Is there a way to get a list of functions that get inlined by dmd?

2010-02-08 Thread Scorn
Trass3r schrieb: Would be interesting. Yes, this would be very interesting indeed. A list of the rules which dmd uses internally for inlining functions and methods similiar to this (which is for .NET) http://blogs.msdn.com/ericgu/archive/2004/01/29/64717.aspx would be really nice. Sure you

Re: Why isn't == used to compare structs

2010-02-08 Thread Jacob Carlborg
On 2/8/10 14:58, Pelle Månsson wrote: On 02/08/2010 01:48 PM, Trass3r wrote: Why isn't == used to compare the struct members in the code above? I mean, if I compare the structs with == it could also use == to compare the members. If I use is to compare the structs it could use is to compare

Re: Why isn't == used to compare structs

2010-02-08 Thread Jacob Carlborg
On 2/8/10 13:48, Trass3r wrote: Why isn't == used to compare the struct members in the code above? I mean, if I compare the structs with == it could also use == to compare the members. If I use is to compare the structs it could use is to compare them members. Structs are compared *bitwise*!

Re: Why isn't == used to compare structs

2010-02-08 Thread Trass3r
Yes, I intentionally duped the string to make sure they're not using the same memory. I was thinking of something like a transitive ==. Overload opEquals.

Re: Is there a way to get a list of functions that get inlined by

2010-02-08 Thread Scorn
bearophile schrieb: Scorn: The only things i figured out so far is that functions across modules do not seem to get inlined (i don't know if this is the case in general) which would be really bad. Another thing which i believe is that functions / methods which contain ref parameters are never

Re: Is there a way to get a list of functions that get inlined by

2010-02-08 Thread Nick Sabalausky
bearophile bearophileh...@lycos.com wrote in message news:hkpiai$2kt...@digitalmars.com... Scorn: The only things i figured out so far is that functions across modules do not seem to get inlined (i don't know if this is the case in general) which would be really bad. Another thing which i

Re: Is there a way to get a list of functions that get inlined by

2010-02-08 Thread Trass3r
Use LDC (D1), you will note a significant improvement over DMD. Unless you're on windows. Yep, second big problem.

Re: Is there a way to get a list of functions that get inlined by

2010-02-08 Thread Scorn
Use LDC (D1), you will note a significant improvement over DMD. Unless you're on windows. Yep, second big problem. And unless you're using CodeBlocks (like me at the moment) for development ...