-
Notifications
You must be signed in to change notification settings - Fork 145
FS-1053 update :: Support instantiation of C#-defined "allows ref struct" generics with ByrefLike types #787
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,6 +336,8 @@ in some situations where capture must be avoided. | |
| * Cannot be static or instance members of a class or normal struct | ||
| * Cannot be captured by any closure construct (async methods or lambda expressions) | ||
| * Cannot be used as a generic parameter | ||
| - In F# 9 and higher, this restriction is relaxed if the generic parameter is defined in C# using the `allows ref struct` anti-constraint. F# can instantiate such generics in types and methods with byref-like types. As a few examples, this affects BCL delegate types (`Action<>`,`Func<>`), interfaces (`IEnumerable<>`,`IComparable<>`) and generic arguments with a user-provided accumulator function (`String.string Create<TState>(int length, TState state, SpanAction<char, TState> action)`) | ||
| - It is impossible to author generic code supporting byref-like types in F#. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be worth expanding on this here? E.g., to mention that the let a : Action<'T> = …
let f (x : 'T) = a.Invoke x // Can 'T be ReadOnlySpan<int> here? Presumably not?let f (g : Action<'T>) (x : 'T) = g.Invoke x // Can 'T be ReadOnlySpan<int> here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not automatically propagated, this makes sense to expand on - thanks for checking this. |
||
|
|
||
| Here is an example: | ||
| ```fsharp | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.