-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Allow pointer types and C# aliases in using
aliases
#2325
Comments
I can't imagine this would be at all difficult to add: if anything I imagine there's custom logic in the compiler that forbids it which would have to be removed. I think the real issue is whether the benefits are strong enough to be worth the effort for the LDM to make the change. It's a rather niche use case. However I think there have been other issues about being able to use type aliases for tuples, as well as for open Generics. There's also been discussion around allowing a type alias to be used globally rather than locally. So perhaps the LDM could take a fresh look at aliases altogether at some point. I imagine they will be connected to roles in some way. Here are the links to other issues around aliases: |
Yeah, I justified it given the fact it is purely compile time, not a breaking change, and simple. I definitely understand it's quite a niche change, but given a general rework of aliases it would definitely be nice. Thanks for the link |
I think all pointer types must need Function pointers
|
The spec specifically mentions that pointers and language keyword aliases become valid expressions in |
@alfasgd Issues here don't get closed until the change is written in the ECMA spec. |
Though #4284 tracks the same feature implementation, and this issue covers a narrower spectrum of the implemented feature, is it fine to have two issues open at the same time like that? Besides, this issue is not even labeled. |
Nope. Duplicates should be closed, thanks. |
Currently this code won't compile:
Neither is the fully qualified name
It would be useful to be able to alias pointer types like this, and alias C# aliases, such as
rather than
The use case at the moment for me is when porting across Win32 methods and structs. I can blindly set all of these to
System.IntPtr
but it is clunky and, importantly, is functionally different, as it is (less) type safe and requires a cast before it can be used as desired (e.g, accessing a member).This is purely compile time logic and as such doesn't seem complex to add, but would be nice for more fully fledged using aliases and for making interop just slightly easier
The text was updated successfully, but these errors were encountered: