"Result" as return value for operator?

Peter N Lewis peter at stairways.com.au
Tue Mar 11 14:06:13 CET 2003


It seems to me that there is a delphi extension where the variable 
Result can be used for any function return value.  Eg:

   function sum( a, b: integer ): integer;
   begin
     Result := a;
     Result := Result + b;
   end;

Given this, I expected operator to work the same way:

   operator + ( a, b: integer ): integer;
   begin
     Result := a + b;
   end;

But this results in "parse error before `:'".

I would think the above operator code should work given the Result 
extension.  Would it make sense to allow this?  Perhaps giving an 
error if the Result extension is disabled?

Thanks,
    Peter.

-- 
<http://www.interarchy.com/>  <http://download.interarchy.com/>




More information about the Gpc mailing list