== Quote from bearophile ([email protected])'s article > Yigal Chripun: > > point in case, look how much > > unnecessary confusion Ranges cause which would be eliminated had D > > allowed for compile-time interfaces. > What are interfaces from the point of view of the compiler?
Abstract classes with only pure virtual functions. In other words, basically under the hood, an interface is just the layout of a vtable. This actually leads to a comment I want to make in the wider debate: I personally find explicit interfaces really, really annoying and I think that duck typing is by far the most intuitive type system there is. I used to program primarily in duck typed languages and resort to every kludge imaginable for speed. What attracted me to D was that the templates and type inference are so powerful that I almost feel like it's still a duck typed language, but much faster and with more error checking. I guess that's why I like ranges so much. Also, while the fact that you need interfaces to specify a vtable layout is an implementation detail, I would argue that, in close to the metal languages, it does more harm than good to try too hard to prevent implementation details from leaking into the language abstractions. Otherwise, what would be the point of it being a close to the metal language? The fact that, for templates, one does not need to specify vtable layouts and for OO you do justifies the asymmetry between templates and OO. Interfaces for templates would just add boilerplate and make explicit something that is already implicitly knowable and checked at compile time anyhow.
