I suggest we ...

Add support for implicit operators to facilitate language interop

Add support for implicit operators to facilitate language interop instead of having to write an explicit operator like:
http://stackoverflow.com/questions/10719770/is-there-anyway-to-use-c-sharp-implicit-operators-from-f

15 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Nelak shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

3 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Nelak commented  ·   ·  Flag as inappropriate

    I'm not proposing to relax strong typing but to add someway to ease language interop.
    I don't see why we can't have something like an [<AllowImplicit>] that would be able to handle implicit operators without sacrificing type safety. In this way you need to opt-in for the desired behaviour

    e.g.:
    [<AllowNull>]

    The null keyword is a valid keyword in the F# language, and you have to use it when you are working with .NET Framework APIs or other APIs that are written in another .NET language. The two situations in which you might need a null value are when you call a .NET API and pass a null value as an argument, and when you interpret the return value or an output parameter from a .NET method call.

  • Daniel Fabian commented  ·   ·  Flag as inappropriate

    I agree, the work-around with a local operator using duck-typing seems like a small cost, when compared to losing the very strong typing we have right now.

F# Language

Feedback and Knowledge Base