Hey guys

Hey guys,

Why Delphi's records doesn't allow interface inheritance?
I want something like this:

Delphi code ->
TEnumerator = record(IEnumerator) <- It isn't allowed
end;

C# code ->
struct Enumerator : IEnumerator { } <- It is allowed

How do I simulate this behavior? :D
Thanks in advance.

Comments

  1. Johan Bontes If you want to implement deferred execution and streaming you need to use interfaces because you need to pass the enumerators around and the implementation for each enumerable differs (see Spring.Collections.Extensions).

    Also unless you just measure the pure time for enumerating a list where it could be inlined to directly use the backing array the overhead for an interface is not that big.
    What might hurt though on x86 is a virtual method behind the interface (default calling convention) because then the compiler generated stub uses xchg (because it does not have any register left) which causes a lock.

    ReplyDelete

Post a Comment