Ranges

Lutger lutger.blijdestijn at gmail.com
Sat Jun 20 03:34:54 PDT 2009


Yigal Chripun wrote:

> dsimcha wrote:
>> == Quote from bearophile (bearophileHUGS at lycos.com)'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.
> 
> That's run-time interfaces. compile-time interfaces are like C++ concepts.
>> 
>> 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.
> 
> duck-typing has its benefits, that's for sure. it all boils down to is
> style issues I guess - do you prefer implicit or explicit interfaces.
> 
> either are fine by me, even though it seems to me that duck-typing is
> more of a dynamically typed language feature but maybe my feeling here
> is wrong.
> either way, the language needs to be consistent about it in order to not
> confuse users unnecessarily.

It's called structural typing in static languages which is almost the same 
but not quite. In duck typing, you can pass an object which does not 
implement the 'required' interface and this is not checked until a missing 
method is actually called. Another way of looking at it is that the 
interface is determined by the path of execution, which is even more 
flexible than structural typing.
 





More information about the Digitalmars-d mailing list