static interface

Leandro Lucarella llucax at gmail.com
Mon Nov 16 13:11:13 PST 2009


Jesse Phillips, el 16 de noviembre a las 13:19 me escribiste:
> Is there a reason not to have all interfaces compile time checked? It
> would still be allowable to state a class implements an interface and
> have the compiler check it.
> 
> The reason I say this is it would remove the complexity of having the
> two types of interfaces. And if you wanted to be able to check for the
> interface at run-time the same interface can be used.

The problem is "regular" interfaces provide dynamic dispatch. Andrei could
implement all the range stuff using interfaces, but that would mean:
1) You have to inherit from the interface (i.e., you can't use arrays)
2) All calls to ranges functions are virtual (inefficient; this is
   particularly relevant since they are called inside loops => lot of
   times)

A static interface don't have those problems, and I don't see a way to mix
static and dynamic interfaces without introducing a "new" type of
interfaces (static interface).

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Si pudiera acercarme un poco más, hacia vos
Te diría que me tiemblan los dos pies, cuando me mirás
Si supieras todo lo que me costó, llegar
Hoy sabrías que me cuesta respirar, cuando me mirás



More information about the Digitalmars-d mailing list