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

Standard FixedArray types in BCL? #102462

Open
xoofx opened this issue May 20, 2024 · 7 comments
Open

Standard FixedArray types in BCL? #102462

xoofx opened this issue May 20, 2024 · 7 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime
Milestone

Comments

@xoofx
Copy link
Member

xoofx commented May 20, 2024

Hey, ☺️

I have been using InlineArray quite extensively in the past months and I love it! Though, one point of difficulty is the fact that it forces to create custom types for a specific kind of array (e.g array of int[4]) which limits the interoperability between libraries.

For example, recently I had to roll out my own set of FixedArray#<T> to be able to use the same type across the different C/C++ interop libraries developed in this project.

A broader related issue is:

But this goes into more difficult territories to get it right language and runtime wise...

So, I'm wondering if having such a type (FixedArray#<T>) builtin in the BCL would be easier to bring (up to e.g 1024 elements, that's the point that is problematic without const literal generic) down into a namespace or a static type (System.FixedArrays) that would not pollute too much the existing namespaces?

Thoughts?

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 20, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label May 20, 2024
@huoyaoyuan huoyaoyuan added area-System.Runtime and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels May 20, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

@xoofx xoofx changed the title Generic FixedArrays in BCL? Standard FixedArray types in BCL? May 20, 2024
@RenderMichael
Copy link
Contributor

RenderMichael commented May 20, 2024

This sounds like the perfect scenario for const generics #89730

@colejohnson66
Copy link

colejohnson66 commented May 22, 2024

As you mentioned, const generics are probably coming in .NET 9. Why would your proposed FixedArrayN<T> be any better than a generic Array<T, N>? Adding a thousand FixedArrayN<T> types to the runtime seems a bit excessive.

@xoofx
Copy link
Member Author

xoofx commented May 22, 2024

As you mentioned, const generics are coming in .NET 9

Oh, where was this announced? I didn't say that they are coming but was actually assuming not anytime soon. It's tagged as milestone on the other issue that I missed, but not sure there is someone taking the lead to challenge it. If that is really coming, yes, that issue can be closed

@EgorBo
Copy link
Member

EgorBo commented May 22, 2024

As you mentioned, const generics are probably coming in .NET 9

There are no plans for them in any version so far, but, perhaps, issues like this will help to move the needle eventually

@colejohnson66
Copy link

Well, #89730 is tagged with the .NET 9 milestone.

@xoofx
Copy link
Member Author

xoofx commented May 22, 2024

Well, #89730 is tagged with the .NET 9 milestone.

When an issue is tagged for a milestone, it just means that it might be evaluated for this milestone, not that it is going to be done. From Egor's comment that is working closely with folks in the .NET teams, it doesn't look like it's coming.

@stephentoub stephentoub added this to the Future milestone Jul 2, 2024
@stephentoub stephentoub added api-suggestion Early API idea and discussion, it is NOT ready for implementation and removed untriaged New issue has not been triaged by the area owner labels Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Runtime
Projects
None yet
Development

No branches or pull requests

6 participants