A couple of days ago I was reading a post about dynamic languages (scripting languages with good PR) on lambda the ultimate. The author wrote “’strong’ typing is not the same as ‘explicit typing’”, which is very true and got me thinking about inferred type system, such as the one F# uses.

<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /> /o:p

The big advantages is that doesn’t seem to be talked about much is that because in inferred type you don’t explicitly say what type an identifier is you get a lot more choice about what you compile it down to. This is especially important in the world of .NET where many different languages could use a library that you produce. F# uses this to be able to support both a generic and non generic CLR with out having use different syntax. This is something that none of the commercially supported languages can offer, and will definitely be supported in the as yet unreleased version 0.7 via –no-generics compiler switch.

 /o:p

For example the following F# code:

 /o:p

let add x = x :: []/o:p

 /o:p

Will compile down to equivalent C#:

 /o:p

public static List<A> add<A>(A x)/o:p

{/o:p

      return new List<A>(x, null);/o:p

}/o:p

 /o:p

However specify the –no-generics switch and the equivalent C# is:

 /o:p

public static List add(object x)/o:p

{/o:p

      return new List(x, null);/o:p

}/o:p

 /o:p

While there’s not going to be a huge number of people who will need this feature, it’s nice to know it’s there.