What's wrong with D's templates?
Lutger
lutger.blijdestijn at gmail.com
Sun Dec 20 09:53:56 PST 2009
Nick Sabalausky wrote:
> "Lutger" <lutger.blijdestijn at gmail.com> wrote in message
> news:hgl440$tlo$1 at digitalmars.com...
>> Yigal Chripun wrote:
>>>
>>> The .Net implementation isn't perfect of course and has a few issues
>>> that should be resolved, one of these is the problem with using
>>> operators. requiring interfaces by itself isn't the problem though. The
>>> only drawback in this case is verbosity which isn't really a big deal
>>> for this.
>>
>> The drawback is not verbosity but lack of structural typing. Suppose some
>> library has code that can be parametrized by IFoo and I have another
>> library
>> with a type that implements IBar, which satisfies IFoo but not explicitly
>> so. Then what? Unless I have totally misunderstood .NET generics, I have
>> to
>> create some proxy object for IBar that implements IFoo just to satisfy
>> the strong type checking of .NET generics. You could make the argument
>> that this
>> 'inconvenience' is a good thing, but I do think it is a bit more of a
>> drawback than just increased verbosity.
>
> It sounds like you're talking about duck typing?
>
>
I'm not sure, I don't think so. From what I understand, duck typing is
supposed to be dynamic, while structural and nominative typing are part of a
static type system. I meant the non-nominative kind of typing, whatever it
is.
fwiw, this is what wikipedia says:
"Duck typing is similar to but distinct from structural typing. Structural
typing is a static typing system that determines type compatibility and
equivalence by a type's structure, whereas duck typing is dynamic and
determines type compatibility by only that part of a type's structure that
is accessed during run time."
http://en.wikipedia.org/wiki/Duck_typing#Structural_type_systems
More information about the Digitalmars-d
mailing list