Theory question
BCS
ao at pathlink.com
Thu May 21 17:07:16 PDT 2009
Reply to Frits,
> BCS wrote:
>
>> Are there any cases where the following cases both compile but are
>> not identical?
>>
>> A a;
>> B b;
>> a = b;
>> a.Foo();
>> //// and
>>
>> A a;
>> B b;
>> a = b;
>> b.Foo();
> struct A {
> int i;
> void Foo() { i = 42; }
> }
> alias A B;
>
> The first case will set a.i to 42, the second will set b.i.
>
I wasn't looking for side effect cases but I guess that is correct.
> And with opAssign + different struct types they'd be calling two
> completely different Foo()s.
>
Oh, forgot opAssign (darn)
> Then there's array types + global function Foo(ref A), union types
> (similar to struct types), class types + static Foo()s (different ones
> for A and B), ...
>
ok looks like to much of a mess to make it work
More information about the Digitalmars-d-learn
mailing list