2014-02-26 13:28 GMT-03:00 Sven Barth <pascaldra...@googlemail.com>: > Am 26.02.2014 16:11, schrieb silvioprog: > > Hello, >> >> I'm trying to add new features in a third generic type. Please see this >> simulation below: >> >> { TThirdGeneric } >> >> generic TThirdGeneric<T> = class >> private >> FFoo: T; >> public >> procedure Post; >> property Foo: T read FFoo; >> end; >> >> { TMyGeneric } >> >> generic TMyGeneric<T> = class(TThirdGeneric) >> > 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>)") > > public >> procedure ConfigureFoo; >> end; >> >> { TMyClass } >> >> TMyClass = class(TMyGeneric) >> > 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<WhateverTypeYouNeed>)". > >> public >> procedure Post; >> end; >> > [snip] > > Just trying to understand the generics concept correctly. :S >> > > Regards, > Sven
Compiled like a charm. I'm loving it. Very very nice! So, I'll implement some methods in a descendant type of this class: https://github.com/silvioprog/brookframework/blob/master/core/brookaction.pas#L262 then: TjTableEditAction = (eaList, eaCreate, eaUpdate, eaDelete); { TjTableEntityAction } generic TjTableEntityAction<T> = class(specialize TBrookEntityAction<T>) public { TODO: implement jTable paging - http://www.jtable.org/apireference#genopt-paging } { TODO: implement jTable edit action - http://www.jtable.org/apireference#Actions } end; And generics will be very helpful in this task. Thank you again Sven! (y) ps. is there any complete documentation about generics in Free Pascal? The Lazarus wiki is a bit incomplete. -- Silvio Clécio My public projects - github.com/silvioprog
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal