Re: [fpc-devel] problem with "is" operator

2005-04-18 Thread DrDiettrich
Linuxer Wang wrote: > > Hello, > > Can anybody tell me how can I know which specific type an instance of > class is? Check the ClassType or ClassName. > The "is" operator seems weird when interface is used. Add a GetObject method to your interfaces, that returns the object that implements the

Re: [fpc-devel] problem with "is" operator

2005-04-18 Thread Uberto Barbini
> >Sometimes I added a GetUnderObject() to my interfaces to get the actual > >object. But it's a choice up to the interface author. > >BTW I needed it to release the object through the interface. > >I suspect that if you shouldn't ever need to know the actual class when > > using interfaces (maybe

Re: [fpc-devel] problem with "is" operator

2005-04-18 Thread Linuxer Wang
Uberto Barbini wrote: It does not seem right to declare var inst: TMyInterface if you want inst to have circles and squares as values. I would expect that you also have a class TFigure, of which TCircle and TSquare both are descendants. These could also implement TMyInterface. You then declare va

Re: [fpc-devel] problem with "is" operator

2005-04-18 Thread Uberto Barbini
> It does not seem right to declare var inst: TMyInterface if you > want inst to have circles and squares as values. I would expect > that you also have a class TFigure, of which TCircle and TSquare > both are descendants. These could also implement TMyInterface. > > You then declare var inst: TF

Re: [fpc-devel] problem with "is" operator

2005-04-18 Thread Tom Verhoeff
On Sun, Apr 17, 2005 at 12:01:36PM -0700, Linuxer Wang wrote: > > Can anybody tell me how can I know which specific type an instance of > class is? The "is" operator seems weird when interface is used. > > Suppose TMyInterface is a interface, and classes TCircle and TSquar > both implements TMyIn

[fpc-devel] problem with "is" operator

2005-04-17 Thread Linuxer Wang
Hello, Can anybody tell me how can I know which specific type an instance of class is? The "is" operator seems weird when interface is used. Suppose TMyInterface is a interface, and classes TCircle and TSquar both implements TMyInterface, and inst:TMyInterface, inst := TCircle.Create. How can I k