Hi Torbjorn,

this issue has been brought up many times before. Take a look here, here and here for example. The reason for this behaviour is name resolution ambiguity between members of different interfaces.

Personally I'd like to be able to specify that an interface is implicitly accessible, perhaps using public or implicit so:

1
2
3
4
5
6
7
8
9
10
11
type IPet =
    abstract Name: string

/// Does not compile!
type MyPet(name) =
    public interface IPet with
        member x.Name   = name

let hutch = MyPet("Hutch")

printfn "%s" hutch.Name

The recommended (and more succinct) way to get this behaviour is to use an object expression so:

1
2
let hutch = {new IPet with member x.Name = "Hutch"}
printfn "%s" hutch.Name

regards,

Danny

By on 9/17/2008 3:32 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper