Inferred type system

 

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.

 

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.

 

For example the following F# code:

 

let add x = x :: []

 

Will compile down to equivalent C#:

 

public static List<A> add<A>(A x)

{

      return new List<A>(x, null);

}

 

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

 

public static List add(object x)

{

      return new List(x, null);

}

 

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.

Bookmark
dotnetkicks+, digg+, reddit+, del.icio.us+, dzone+, facebook+

Print | posted @ Tuesday, September 14, 2004 8:52 PM

Comments on this entry:

No comments posted yet.

Your comment:

(Note: all comments are moderated so it may take sometime to appear)

Title:
Name:
Email:
Website:
 
Italic Underline Blockquote Hyperlink
 
 
Please add 4 and 1 and type the answer here:
 

Links

 Subscribe in a reader
Twitter Follow me on Twitter
FaceBook View my Facebook
LinkedIn View my LinkedIn Profile Viadeo Viadeo Profile (Français)

Badges


Progressive .NET Tutorials 2009

Disclaimer

The views expressed on this weblog are mine and do not necessarily reflect the views of my employer.

All postings are provided "AS IS" with no warranties, and confer no rights.

www.flickr.com
This is a Flickr badge showing public photos and videos from Robert Pickering. Make your own badge here.