-
Notifications
You must be signed in to change notification settings - Fork 4.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
Tuple types in using directives #15072
Comments
🍝 Generic version when combined with #3993? using Subject<T> = (T Gender, double Age); |
That's pretty cool! |
At first glance, this seems an excellent idea. But then it takes on the texture of "aerosol cream": it looks like rich, thick, real cream but turns out to be 90% air. Yes, it would be useful occasionally, but the scope would then just be within that file. Some means of giving it a wider scope would really make this useful, eg: Subject.cs public global Subject<T> = (T Gender, double Age); OtherFile.cs bool GetGender(Subject<bool> subject) => subject.Gender;
var gender = GetGender((false, 10)); Update |
@DavidArno this was previously rejected for some reason #7451. |
@dsaf, |
I'm happy with the proposal as @gafter specified. I think generics and global scope are both orthogonal to this feature and should be considered separately. |
Generics and global scope are enhancements to the basic proposal. So you appear to be misusing the term "orthogonal" 😛 |
@DavidArno They are completely separable proposals that do not impact the merits of this feature as proposed. I'd call that orthogonal. Scope creep is the death of feature requests. |
I don't see this necessary. It is at best low priority. If you want a type, define a type. |
Once we have records, it'll be a piece of cake. struct Subject(bool Gender, double Age); I'd personally prefer to have generic and global type aliases over this. |
@DavidArno records do not cover all the use cases you might need aliases for. See my example in #7453, there's no way a record can replace a long-winded generic interface type declaration. |
Apologies, my comment wasn't clear. I was referring to this specific feature request: tuple aliases, not type aliases in general. I've updated my comment to fix that. |
@DavidArno I'm saying that when you want a named tuple you'd better to define a struct record. But generic and global type aliases are useful for other scenarios, regardless of this proposal. |
Will the diposable form of using also be supported. using ( ( MyDisposable0, MyDisposable1 ) )
[
...
} |
@AdamSpeight2008 This is already supported: using (IDisposable d1 = e1, d2 = e2) {} |
@alrz That's not what I'm asking.
And it is call within the header of a using block.
Do the |
@HaloFour If the tuple is decomposed into separate variables, we risk the chance of disposing of a copy. |
That proposal goes over several potential implementations. Either way, this proposal is about |
@gafter Should this be moved to csharplang? |
@jcouv yes, I'll move it. |
Issue moved to dotnet/csharplang #423 via ZenHub |
It has been requested that we support
The text was updated successfully, but these errors were encountered: