<div class="gmail_quote"><span style="font-family:courier new,monospace">2013/3/22 Sven Barth <span dir="ltr"><<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a>></span><br></span><div>
<span style="font-family:courier new,monospace"> </span></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span style="font-family:courier new,monospace">> The problem is gone, because PNode is not a generic class, but only a record. However, the following errors are generated:</span>
<p><span style="font-family:courier new,monospace">2.6.x does not support nested types in generics. Generic fixes and improvements are only found in 2.7.1 as most of them were to invasive to be merged back.</span></p></blockquote>
<div><span style="font-family:courier new,monospace">OK, then why this error happened:<br><br>demo2.lpr(76,13) Error: Incompatible types: got "TRoller.TTreap$PPerson$Byte" expected "TRoller"<br> <br>The problematic lines are:<br>
<br>=== demo2.lpr ===<br><br>var<br> n: TRoller.PNode;<br> r1, r2: TRoller;<br>begin<br> r1 := TRoller.Create;<br> with r1 do begin<br> ... ...<br> <b><span style="color:rgb(255,0,0)"> r2 := r1.Copy(@OrderByAge);</span></b><br>
... ...<br> end;<br>end. <br><br>=== treap.pas ===<br><br>function TTreap.Copy(Comp: TComparator): TTreap;<br>var<br> n: PNode;<br>begin<br> if Comp = nil then Comp := FComparator;<br> Result := TTreap.Create;<br>
Result.Comparator := Comp;<br> for n in Self do Result.Insert(n^.Key, n^.Value);<br>end;<br><br>I don't see there are "nested types" and why there is a type named: </span><span style="font-family:courier new,monospace">TRoller.TTreap$PPerson$Byte? Shouldn't be either </span><br>
<span style="font-family:courier new,monospace">TRoller or TTreap$PPerson$Byte but not both?<br><br>Thanks,<br>Xiangrong<br></span></div></div>