[fpc-devel] Interface: Method resolution clauses
Marcos Douglas
md at delfire.net
Mon Apr 30 17:06:50 CEST 2012
Hi,
Can I, using FPC trunk, do this sintaxe?
type
TMemoryManager = class(TInterfacedObject, IMalloc, IErrorInfo)
function IMalloc.Alloc = Allocate;
procedure IMalloc.Free = Deallocate;
...
end;
I'm using 2.6.1 and do not works.
>From Dephi's (7) help:
----------------------------------
"You can override the default name-based mappings by including method
resolution clauses in a class declaration. When a class implements two
or more interfaces that have identically named methods, use method
resolution clauses to resolve the naming conflicts.
A method resolution clause has the form
procedure interface.interfaceMethod = implementingMethod;
or
function interface.interfaceMethod = implementingMethod;
where implementingMethod is a method declared in the class or one of
its ancestors. The implementingMethod can be a method declared later
in the class declaration, but cannot be a private method of an
ancestor class declared in another module.
For example, the class declaration
type
TMemoryManager = class(TInterfacedObject, IMalloc, IErrorInfo)
function IMalloc.Alloc = Allocate;
procedure IMalloc.Free = Deallocate;
...
end;
maps IMalloc's Alloc and Free methods onto TMemoryManager's Allocate
and Deallocate methods.
A method resolution clause cannot alter a mapping introduced by an
ancestor class."
Thanks,
Marcos Douglas
More information about the fpc-devel
mailing list