Type system question

bearophile bearophileHUGS at lycos.com
Wed Dec 10 18:56:07 PST 2008


Bill Baxter:
> I'm curious if such strong type inference ideas could improve D.  It's
> interesting, but really the example I came up with above has done
> little to convice me of the value.  So I'm also hoping, Bearophile,
> that you can provide some convincing examples of the power of stronger
> type inference.

I like to learn and discuss, I'm not here to convince people :-)
A strong type inferencer can of course allow the compiler to find by itself all the types used into a function, as in the ML language.
An even more complex type inferencer can even infer all the types of your program, this is what ShedSkin (and the Stalin Scheme compiler) does when you feed it with Python code. But such global type inferencing requires a lot of time for the compiler (and such time grows in a superlinear way), so I consider ShedSkin a failed experiment...

So my point in a possible more flexible type system was not in creating a new kind of full type inferencer.
A flexible type system allows you to do few of the things you can see in the Scala language, or even ones in Haskell. Like managing type classes, etc. This purpose expands the number of things the type system can do for you, but also forces the programmer to learn some new things, that aren't present in C. So the language gets a little (or more than a little) more complex.

So you can see at my original "proposal" as the idea of creating a statically compiled language like Scala, that can be used a C too. (But Scala has several things I don't like, so lot of syntax has to be removed and other lower-level things to be added). Note there's already a language a bit like this, the ATS, but for me it's ugly (here there are unusually ugly examples because the author has done any thing to reach the performance of C, the result is much less readable than C itself):
http://shootout.alioth.debian.org/u32/

Bye,
bearophile



More information about the Digitalmars-d mailing list