[fpc-devel] Considerations about observer [was: Free Pascal 2.6.2 rc1]
luiz americo pereira camara
luizmed at oi.com.br
Wed Nov 28 15:40:55 CET 2012
2012/11/28 <michael.vancanneyt at wisa.be>:
>
>
> On Tue, 27 Nov 2012, luiz americo pereira camara wrote:
>
>> 2012/11/27 Michael Van Canneyt <michael at freepascal.org>:
>> As practical example take a LCL Form that is supposed to be observed.
>> It takes an Observer property and attach it to certain child controls
>> (TEdit etc)
>>
>> 1) Currently i'm forced to declare as the Observer property as an
>> TObject. If i declare Observer property as IFPObserver i cannot attach
>> to children controls.
>
> I do not understand this ?
>
I can post a simple example showing what i mean
I'll do today later. Currently i don't have access for a computer with fpc
>> 2) Each time i attach to a child control this Observer property will
>> be queried to see if implements IFPObserver (but we already know that
>> it implements, we already checked !!!)
>
>
> You only gain speed when notifying. When calling FPOAttachAbserver or
> FPODetachAbserver, you would need to typecast some object anyway if we would
> change the interface, so there is no speed gain there...
In this case there's a gain.
The typecast would be done once when setting the parent property (IFPObserver)
Afterwards (setting children) would be no typecast, different as today
>
> During notification, we can gain speed by internally storing the interface.
>
OK. Seems here that we pacify the point of the reference count (not)
requirement to store the interface pointer
>
>> So, i keep my points. Even because is not a big change with easy
>> implementation that will fix the above issues.
>
>
> It IS a big change. There is production code out there that uses this,
> and this is an incompatible change.
1) The change in code can be tedious but is simple. from Attach(MyObj)
to Attach(MyObj as IFPObserver)
2) I 'm assuming this as the first public release for wide test so the
best moment for such change
Luiz
More information about the fpc-devel
mailing list