Skip to content

Remaining work for discards, tuples and out variables #768

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

Open
3 of 6 tasks
MadsTorgersen opened this issue Apr 6, 2023 · 7 comments
Open
3 of 6 tasks

Remaining work for discards, tuples and out variables #768

MadsTorgersen opened this issue Apr 6, 2023 · 7 comments
Assignees
Labels
type: clarity While not technically incorrect, the Standard is potentially confusing
Milestone

Comments

@MadsTorgersen
Copy link
Contributor

MadsTorgersen commented Apr 6, 2023

I'm using this issue to evacuate remaining unresolved conversations and pending improvements from PR #664, so that it can get merged without losing track of them.

  • More examples: Several parts of the PR are short on examples, e.g.:
  • Annotation of examples for testing
  • Tuple encoding(https://github.com/dotnet/csharpstandard/pull/664/files#r1145298345, https://github.com/dotnet/csharpstandard/pull/664/files#r1145285224):

    The compiler usually constructs the underlying ValueTuple<> chain. If the program constructs an n-tuple directly using ValueTuple<> then is the code potentially non-portable between implementations which declare a different number of ValueTuple<> sizes? Or does the compiler accept only flat new ValueTuple…?
    This says an n-tuple in different implementations could be represented by a chain of q m-tuples and a final p-tuple where n = q × (m-1) + p and m is implementation dependent number. Do we need to say anything about how one implementation handles tuple values created by another with a different m?

  • Declaration spaces (https://github.com/dotnet/csharpstandard/pull/664/files#r1112356059):

    Additional contexts that might not be covered by this yet:

    • Pattern variables declared in a switch (case) label. This one is subtle because it introduces a scope that encompasses just the switch section, nested within the switch block, but local variables declared in the statements of the switch section go in the scope of the switch block.
    • A switch case guard (when clause). These go in just the switch block's scope (see previous bullet).
    • A query clause
    • A catch block, where the exception variable is introduced. Its absence looks like a bug in the previous version. This will take care of expression variables in an exception filter as well.
@MadsTorgersen MadsTorgersen self-assigned this Apr 6, 2023
@jskeet jskeet assigned jskeet and unassigned MadsTorgersen May 17, 2023
@jskeet jskeet added this to the C# 7.x milestone May 17, 2023
@jskeet
Copy link
Contributor

jskeet commented May 17, 2023

I'll check that these were done in the end (or create a PR, or ask for more help).

@jskeet
Copy link
Contributor

jskeet commented Jun 2, 2023

More examples: this is a nice-to-have. We should do it, but it shouldn't block the C# 7 standard from going out.

Annotation of examples for testing: I believe Rex has done these; @RexJaeschke can you confirm?

Tuple encoding: I'm not sure whether it was present before, but we have this note:

Note: There does not need to exist a System.ValueTuple<...> declaration that directly matches the arity of any tuple type with a corresponding number of type parameters. Instead, larger tuples can be represented with a special overload System.ValueTuple<..., TRest> that in addition to tuple elements has a Rest field containing a nested tuple value of the remaining elements. Such nesting may be observable in various ways, e.g. via the presence of a Rest field. end note

Proposal: I'll create a PR to add this to annex B.3.

Declaration spaces:

  • I note that we don't cover declaration_pattern at all in section 7.7.1, which is the first place I looked. Is that a problem?
  • The rest of the "work to be done" looks like it still needs to be done. @gafter you originally raised this - are you in a good position to create a PR to address it?

@RexJaeschke
Copy link
Contributor

@jskeet

Annotation of examples for testing: I believe Rex has done these; @RexJaeschke can you confirm?

I have done this for PRs merged up to the most recent meeting. At that meeting, we closed PR #742, which I see has 4 new, small examples (in variables.md). I plan to add annotation to these after tomorrow's call, when I will do likewise for PR #795, assuming we merge that.

@KalleOlaviNiemitalo
Copy link
Contributor

7.6 Signatures and overloading states that object and dynamic are equivalent in signatures.

The types `object` and `dynamic` are not distinguished when comparing signatures. Therefore members declared in a single type whose signatures differ only by replacing `object` with `dynamic` are not allowed.

It is not necessary to add a sentence saying that tuple element names do not affect signature equality, because this follows from the identity conversions that are already specified.

- Two signatures of the same member kind (method, instance constructor, indexer or operator) are considered to be the *same signatures* if they have the same name, number of type parameters, number of parameters, and parameter-passing modes, and an identity conversion exists between the types of their corresponding parameters ([§10.2.2](conversions.md#1022-identity-conversion)).
In some cases there is an identity conversion between types that are not exactly the same, but are considered equivalent. Such identity conversions exist:
- between `object` and `dynamic`.
- between tuple types with the same arity, when an identity conversion exists between each pair of corresponding element types.
- between types constructed from the same generic type where there exists an identity conversion between each corresponding type argument.

@jskeet jskeet assigned MadsTorgersen and unassigned jskeet Sep 6, 2023
@jskeet
Copy link
Contributor

jskeet commented Sep 6, 2023

Meeting 2023-09-06:

  • "More examples" can be a maintenance task, post C# 7 release (or potentially while it's out for ECMA review)
  • Declaration spaces work assigned back to Mads

@jskeet
Copy link
Contributor

jskeet commented Sep 20, 2023

Closing, as we'd like more examples, but the blocking aspects are done.

@jskeet jskeet closed this as completed Sep 20, 2023
@jskeet jskeet modified the milestones: C# 7.x, C# 8.0 Sep 20, 2023
@jskeet jskeet added the type: clarity While not technically incorrect, the Standard is potentially confusing label Sep 20, 2023
@jskeet
Copy link
Contributor

jskeet commented Sep 20, 2023

Reopening with C# 8 milestone and clarity label for the examples.

@jskeet jskeet reopened this Sep 20, 2023
@jskeet jskeet modified the milestones: C# 8.0, Pre-C# 8.0 Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: clarity While not technically incorrect, the Standard is potentially confusing
Projects
None yet
Development

No branches or pull requests

4 participants