What's wrong with D's templates?

retard re at tard.com.invalid
Mon Dec 21 03:25:04 PST 2009


Mon, 21 Dec 2009 04:05:01 -0700, Rainer Deyke wrote:

> yigal chripun wrote:
>> Rainer Deyke Wrote:
>>> I prefer to think of option 2 as explicitly typed while option 3 uses
>>> type inference.  Type inference is a good thing.
> 
>> You might prefer that but it's incorrect.
> 
> It's not incorrect, it's another way of looking at the same thing.
> Structural type inference and

> compile-time dynamic typing are the same
> thing.

Now that's a funny term.. you see

dynamic = runtime
static = compile-time

"compile type dynamic X" is a paradox. And so is "runtime static X"

Another note, dynamic types do have a compile time representation. On 
type system level the types all have a 'dynamic' type. Not much can be 
said about that unless e.g. pattern matching is used. Static structural 
types on the hand differ on compile time. They have some kind of 
structure. What type inference means in this context is that instead of

  typeof({type has members a and b}) foo = { a = 2, b = 3 }

you can say

  auto foo = { a = 2, b = 3 }

Now if you try to do

  auto foo = 1;
  foo = { a = 2, b = 3 }

you get a compile time error. With dynamic types that is not a compile 
time nor runtime error.



More information about the Digitalmars-d mailing list