Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

voidptr should be considered as an unmanaged type #1160

Closed
5 tasks done
Happypig375 opened this issue Jun 24, 2022 · 3 comments
Closed
5 tasks done

voidptr should be considered as an unmanaged type #1160

Happypig375 opened this issue Jun 24, 2022 · 3 comments

Comments

@Happypig375
Copy link
Contributor

Happypig375 commented Jun 24, 2022

dotnet/fsharp#11424
Currently F# does not treat voidptr as an unmanaged type. Therefore types like nativeptr<voidptr>, etc. cause compiler errors.

However on IL level this works and C# libraries (e.g. Silk.NET.OpenGL) expose methods expecting this kind of argument (which currently can't be created in F# due the above)
image

The existing way of approaching this problem in F# is to make use of C# to wrap around problematic methods.

Pros and Cons

The advantages of making this adjustment to F# are

  1. Consistency with C#
  2. Convenience
  3. Less surprises

The disadvantages of making this adjustment to F# are that native interop is not an area F# focuses on. However, it's still beneficial to unblock scenarios where we must make use of C#.

Extra information

Estimated cost (XS, S, M, L, XL, XXL): XS to S

Related suggestions: dotnet/fsharp#11424

Affidavit (please submit!)

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I or my company would be willing to help implement and/or test this

For Readers

If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.

@reijerh
Copy link

reijerh commented Jun 28, 2022

Agree, in practice I currently often just fall back to nativeint to work around type juggling headaches that arise because of this.

@cartermp
Copy link
Member

cartermp commented Oct 3, 2022

Agreed, this feels like something that's just the right thing to do. I have approved this in principle. While I cannot speak for the priority of the team to implement, I think this would also make a fine contribution to F# vNext.

@realvictorprm
Copy link
Member

@cartermp I believe this can be closed now that dotnet/fsharp#15725 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants