--
--
To post, send email to fsharp-o...@googlegroups.com
To unsubscribe, send email to
fsharp-opensou...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/fsharp-opensource
---
You received this message because you are subscribed to the Google Groups "F# Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fsharp-opensou...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
type DiscreteEventCounter = { mutable Total : int; mutable Positive : int; Name : string }let newCounter nm = { Total = 0; Positive = 0; Name = nm }
Actually, come to think of it… Maybe a less intrusive approach could be useful in practice…
How about we’d add either an implicit (or probably more likely) keyword to create a wrapper interface;
type IDuck =
abstract member Quack : unit -> string
abstract member Fly : unit -> unit
let bird1 = MyDuckNotImplementingIDuck()
let fly (duck:IDuck) =
duck.Fly()
let quack (duck:IDuck) =
duck.Quack()
// new F# feature
fly bird1 // implicit wrapper like { new IDuck with member Fly () = bird1.Fly(); Quack () = bird1.Quack() }
// more explicit syntax
fly (adopt bird1)
in both cases, though, the F# compiler can do the necessary compatibility checks on the call-site.
Actually, come to think of it… Maybe a less intrusive approach could be useful in practice…
How about we’d add either an implicit (or probably more likely) keyword to create a wrapper interface;
type IDuck = abstract member Quack : unit -> string abstract member Fly : unit -> unit let bird1 = MyDuckNotImplementingIDuck() let fly (duck:IDuck) = duck.Fly() let quack (duck:IDuck) = duck.Quack() // new F# feature fly bird1 // implicit wrapper like { new IDuck with member Fly () = bird1.Fly(); Quack () = bird1.Quack() } // more explicit syntax fly (adopt bird1)
in both cases, though, the F# compiler can do the necessary compatibility checks on the call-site.
--