Skip to content

foreach expansions, value collections. #1720

Description

@BillWagner

This is a followup to the issue transferred to dotnet/roslyn#84307

This does uncover questions on how we should describe foreach, and how we specify the behavior of identity conversions:

  • Identity conversions and creating a copy: In v3, the language for an identity conversion did not prohibit copying the target. In v5 that language was added, seemingly to prohibit copying a struct. Initial analysis indicates this prohibition is correct. Is there any text on conversions that could be interpreted as allowing a copy for an identity conversion?
  • Should the description of foreach make it clear that a value based collection could be mutated? Is that necessary in the normative language?
  • Should we return to 2 expansions of foreach? One where the collection type has the necessary public members, and one where the collection type explicitly implements the expected interfaces?

There are a number of forward looking comments here: dotnet/roslyn#84307 (comment) When we reach the versions where ref struct types are allowed to implement some interfaces, we'll need to address some of them.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions