Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Xiangrong Fang
I know it is same but why no error on the line: for n in sm1.reversed... regards. 在 2013-9-24 下午11:23,"Sven Barth" 写道: > Am 24.09.2013 17:14, schrieb Xiangrong Fang: > > 2013/9/24 Sven Barth > > >> How is PNode declared? What is the exact error? >> >> > PNode is declared inside TTreap generi

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Sven Barth
Am 24.09.2013 17:32, schrieb Xiangrong Fang: I know it is same but why no error on the line: for n in sm1.reversed... n is of type TStringMapper.PNode whereby PNode is declared inside TTreap and thus the type is in reality a TTreapString>. sm1.reversed returns a TTreap which has an enumerator

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Sven Barth
Am 24.09.2013 17:14, schrieb Xiangrong Fang: 2013/9/24 Sven Barth > How is PNode declared? What is the exact error? PNode is declared inside TTreap generic class, the source is here: https://github.com/xrfang/fpcollection/blob/master/src/units/treap.pas

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Xiangrong Fang
2013/9/24 Sven Barth > How is PNode declared? What is the exact error? > > PNode is declared inside TTreap generic class, the source is here: https://github.com/xrfang/fpcollection/blob/master/src/units/treap.pas The exact error is: Error: Incompatible types: got "TStringMapper.TTreap$AnsiStr

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Sven Barth
Am 24.09.2013 15:50, schrieb Xiangrong Fang: Hi Sven, 2013/9/23 Xiangrong Fang mailto:xrf...@gmail.com>> Short answer: you can't. The same would happen with normal classes. Long answer: You could add an additional method "Next" to your "TIntTree" which returns a

Re: [fpc-pascal] Incompatible type for generics?

2013-09-24 Thread Xiangrong Fang
Hi Sven, 2013/9/23 Xiangrong Fang > Short answer: you can't. The same would happen with normal classes. >> >> Long answer: You could add an additional method "Next" to your "TIntTree" >> which returns a "TIntTree" and just do "Result := TIntTree(inherited >> Next);" there. >> > I still have pro

Re: [fpc-pascal] Incompatible type for generics?

2013-09-23 Thread Xiangrong Fang
> Short answer: you can't. The same would happen with normal classes. > > Long answer: You could add an additional method "Next" to your "TIntTree" > which returns a "TIntTree" and just do "Result := TIntTree(inherited > Next);" there. > > Why are you subclassing in this case anyway? > Thanks, I wi

Re: [fpc-pascal] Incompatible type for generics?

2013-09-23 Thread Sven Barth
Am 23.09.2013 09:10 schrieb "Xiangrong Fang" : > > Hi All, > > I wrote a TTree generic class, the code is here: > > https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas > > While using this class, I encountered the following problem: > > program project1; > {$mode objfpc}{$H+} > us

[fpc-pascal] Incompatible type for generics?

2013-09-23 Thread Xiangrong Fang
Hi All, I wrote a TTree generic class, the code is here: https://github.com/xrfang/fpcollection/blob/master/src/units/tree.pas While using this class, I encountered the following problem: program project1; {$mode objfpc}{$H+} uses tree; type TIntTree = class(specialize TTree) end; var ti