<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-02-26 13:28 GMT-03:00 Sven Barth <span dir="ltr"><<a href="mailto:pascaldragon@googlemail.com" target="_blank">pascaldragon@googlemail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Am 26.02.2014 16:11, schrieb silvioprog:<div class=""><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hello,<br>
<br>
I'm trying to add new features in a third generic type. Please see this simulation below:<br>
<br>
{ TThirdGeneric }<br>
<br>
generic TThirdGeneric<T> = class<br>
private<br>
FFoo: T;<br>
public<br>
procedure Post;<br>
property Foo: T read FFoo;<br>
end;<br>
<br>
{ TMyGeneric }<br>
<br>
generic TMyGeneric<T> = class(TThirdGeneric)<br>
</blockquote></div>
This must be "class(specialize TThirdGeneric<T>)" (the "T" is the same type parameter as specified for the "TMyGeneric" declaration, so if it would be "TMyGeneric<MyType>" it would need to be "class(specialize TThirdGeneric<MyType>)")<div class="">
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
public<br>
procedure ConfigureFoo;<br>
end;<br>
<br>
{ TMyClass }<br>
<br>
TMyClass = class(TMyGeneric)<br>
</blockquote></div>
A class parent must always be a specialization as generics are no valid types per se. So here the correct declaration would again be "class(specialize TMyGeneric<<u></u>WhateverTypeYouNeed>)".<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
public<br>
procedure Post;<br>
end;<br>
</blockquote>
[snip]<div class=""><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Just trying to understand the generics concept correctly. :S<br>
</blockquote>
<br></div>
Regards,<br>
Sven</blockquote></div><div><br></div><div><div>Compiled like a charm. I'm loving it. Very very nice!</div><div><br></div><div>So, I'll implement some methods in a descendant type of this class:</div><div><br></div>
<div><a href="https://github.com/silvioprog/brookframework/blob/master/core/brookaction.pas#L262">https://github.com/silvioprog/brookframework/blob/master/core/brookaction.pas#L262</a></div><div><br></div><div>then:</div>
<div><br></div><div> TjTableEditAction = (eaList, eaCreate, eaUpdate, eaDelete);</div><div><br></div><div> { TjTableEntityAction }</div><div><br></div><div> generic TjTableEntityAction<T> = class(specialize TBrookEntityAction<T>)</div>
<div> public</div><div> { TODO: implement jTable paging - <a href="http://www.jtable.org/apireference#genopt-paging">http://www.jtable.org/apireference#genopt-paging</a> }</div><div> { TODO: implement jTable edit action - <a href="http://www.jtable.org/apireference#Actions">http://www.jtable.org/apireference#Actions</a> }</div>
<div> end;</div><div><br></div><div>And generics will be very helpful in this task.</div></div><div><br></div><div>Thank you again Sven! (y)</div><div><br></div><div>ps. is there any complete documentation about generics in Free Pascal? The Lazarus wiki is a bit incomplete.</div>
<div><br></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>