What is the difference between this two F# type functions:
let defaultInstance1<'a when 'a:(new: unit->'a)> = new 'a()
[<GeneralizableValue>]
let defaultInstance2<'a when 'a:(new: unit->'a)> = new 'a()
Here is a good blog:
http://blogs.msdn.com/b/mulambda/archive/2010/05/01/value-restriction-in-f.aspx (archived here ).
It takes a bit of reading to get to the GeneralizableValue
part, but if you get there, I think you will understand it. :)
let defaultInstance1<'a when 'a:(new: unit->'a)> = new 'a()
[<GeneralizableValue>]
let defaultInstance2<'a when 'a:(new: unit->'a)> = new 'a()
let x1 = defaultInstance1 // value restriction
let x2 = defaultInstance2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.