[fpc-pascal] Question about interfaces and patch

Marcel Martin mm10 at ellipsa.net
Fri Mar 25 00:38:01 CET 2005


Michael Van Canneyt wrote:

>>> On Thu, 24 Mar 2005 ml at brainwashers.org wrote:
>>
>> procedure MyXYZPart.DoReport(aRep: IReportable);
>> begin
>>  if (aRep <> nil) then begin
>>    if (aRep is ILogged) then
>>      (aRep as ILogged).Log(aRep.Report)
>>    else
>>      aRep.Report
>> end;
> 
> 
> I see what you want, but if you would do
> 
> procedure MyXYZPart.DoReport(aRep: TInterfacedObject);
> 
> begin
>   if (aRep <> nil) and arep is IReportable then begin
>     if (aRep is ILogged) then
>       (aRep as ILogged).Log(aRep.Report)
>     else
>       aRep.Report
> end;
> 
> you would have the same effect ?


Yes, in both cases, the compiler will stop because of a "begin"
without a "end". ;-)

More seriously, each time I see a "then begin", maybe I am wrong
but I immediately think that I have to deal with some code written
by a C programmer. And, curiously, I cannot find it reassuring.

mm







More information about the fpc-pascal mailing list