<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">Ryan Joseph <<a href="mailto:ryan@thealchemistguild.com">ryan@thealchemistguild.com</a>> schrieb am Di., 4. Sep. 2018, 11:27:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Sep 4, 2018, at 2:06 PM, Ryan Joseph <<a href="mailto:ryan@thealchemistguild.com" target="_blank" rel="noreferrer">ryan@thealchemistguild.com</a>> wrote:<br>
> <br>
> Sorry I didn’t think enough before I sent this.<br>
> <br>
> We *must* allow this assignment to make operator overloads work. += operators are also basically assigning TWrapper to TWrapper, right? I guess we need to break the default property behavior is instances that the same type is being assigned to itself but correct me if I’m wrong.<br>
> <br>
> var<br>
> wrapper: TWrapper;<br>
> <br>
> wrapper += 10;<br>
<br>
Some questions about operator overloads.<br>
<br>
1) rec := 1; should resolve to rec.num := 1 obviously.<br>
<br>
2) rec += 10; should call the function TWrapper.+ right? It could operate directly on the field “num” but then the actual function wouldn’t be called.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Would you please stop thinking with the C operators? They are merely syntactic sugar and they don't exist by themselves. For this topic at least please stick to their full versions (in your example "rec := rec + 10") as that highlights better what the compiler needs to handle. In this case both the + *and* the assignment operator. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
3) should writeln(rec); resolve to writeln(rec.num); or be a syntax error? If it resolves to rec.num then passing around the record would technically just pass the num field and not the record. That doesn’t sound right to me. Without thinking about it much it feels like “rec” in isolation should be treated as the base type, ie. TWrapper.<br>
<br>
4) I guess := operator overloads for records with a default property should be disabled, right? Otherwise they present a conflict that needs to be resolved.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">The idea of the default property is that *all* operators (and methods) (except management operators) are hoisted from the type of the default property. The assignment of one record with default property to another of the same type is handled by the Copy management operator. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"></div></div></div>