Re: [fpc-pascal] casting interfaces and objects

2008-05-19 Thread Martin Schreiber
On Monday 19 May 2008 00.02:55 Marc Santhoff wrote: > Am Sonntag, den 18.05.2008, 23:41 +0200 schrieb Graeme Geldenhuys: > > 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > > > Since the compiler dod not warn about using the "as" operator I assume > > > it is safe? Like this: > > > > > > procedure T

Re: [fpc-pascal] casting interfaces and objects

2008-05-19 Thread Marc Santhoff
Am Montag, den 19.05.2008, 09:16 +0200 schrieb Graeme Geldenhuys: > Marc Santhoff wrote: > > Am Sonntag, den 18.05.2008, 23:41 +0200 schrieb Graeme Geldenhuys: > >> 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > >>> Since the compiler dod not warn about using the "as" operator I assume > >>> it is

Re: [fpc-pascal] casting interfaces and objects

2008-05-19 Thread Graeme Geldenhuys
Marc Santhoff wrote: Am Sonntag, den 18.05.2008, 23:41 +0200 schrieb Graeme Geldenhuys: 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: Since the compiler dod not warn about using the "as" operator I assume it is safe? Like this: procedure TObservable.DeRegister( obsv: IObserver ); var i:

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Marc Santhoff
Am Sonntag, den 18.05.2008, 23:41 +0200 schrieb Graeme Geldenhuys: > 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > > Since the compiler dod not warn about using the "as" operator I assume > > it is safe? Like this: > > > > procedure TObservable.DeRegister( obsv: IObserver ); > > var > >i:

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Graeme Geldenhuys
2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > Since the compiler dod not warn about using the "as" operator I assume > it is safe? Like this: > > procedure TObservable.DeRegister( obsv: IObserver ); > var >i: integer; > begin >if (fObservers.count<=0) then exit; >for i:=0 t

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Marco van de Voort
> Am Sonntag, den 18.05.2008, 23:07 +0200 schrieb Marco van de Voort: > begin > if (fObservers.count<=0) then exit; > for i:=0 to fObservers.count-1 do begin > if ((fObservers[i] as IObserver)=obsv) then begin > fObservers.delete(i); >

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Marc Santhoff
Am Sonntag, den 18.05.2008, 23:07 +0200 schrieb Marco van de Voort: > > I have two questions about interface usage. > > > > 1. How interfaces are to handle when casting? > > Theoretically it should be safe to do this: > > > > TObservable = class > > public > > procedure Register( obsv: IObserve

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Marc Santhoff
Am Sonntag, den 18.05.2008, 17:54 -0300 schrieb Joao Morais: > Marc Santhoff wrote: > > Hi, > > > > I have two questions about interface usage. > > > > 1. How interfaces are to handle when casting? > > Theoretically it should be safe to do this: > > > > TObservable = class > > public > > proce

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Marc Santhoff
Am Sonntag, den 18.05.2008, 22:51 +0200 schrieb Graeme Geldenhuys: > 2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > > When using a cast from an interface to an object the compiler warns > > about the class types "TObject" and "IObserver" not being related. > > > > Since an implementor of in interfa

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Marco van de Voort
> I have two questions about interface usage. > > 1. How interfaces are to handle when casting? > Theoretically it should be safe to do this: > > TObservable = class > public > procedure Register( obsv: IObserver ); > private > procedure NotifyObservers(param: TParameter); > fObservers: TFP

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Joao Morais
Marc Santhoff wrote: Hi, I have two questions about interface usage. 1. How interfaces are to handle when casting? Theoretically it should be safe to do this: TObservable = class public procedure Register( obsv: IObserver ); private procedure NotifyObservers(param: TParameter); fObserver

Re: [fpc-pascal] casting interfaces and objects

2008-05-18 Thread Graeme Geldenhuys
2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>: > When using a cast from an interface to an object the compiler warns > about the class types "TObject" and "IObserver" not being related. > > Since an implementor of in interface always will be a class type and any > class type at least inherits from TO

[fpc-pascal] casting interfaces and objects

2008-05-18 Thread Marc Santhoff
Hi, I have two questions about interface usage. 1. How interfaces are to handle when casting? Theoretically it should be safe to do this: TObservable = class public procedure Register( obsv: IObserver ); private procedure NotifyObservers(param: TParameter); fObservers: TFPObjectList; end;