8000 [Feature Request] Implement `CollectionElement` trait to conform to `EqualityComparable` trait · Issue #2238 · modular/modular · GitHub
[go: up one dir, main page]

Skip to content
[Feature Request] Implement CollectionElement trait to conform to EqualityComparable trait #2238
@arvindavoudi

Description

@arvindavoudi

Review Mojo's priorities

What is your request?

For the proposed List.index method to be operational, it is essential to first implement the CollectionElement trait to conform to the EqualityComparable trait. This prerequisite ensures that the types used within the List struct are comparable (equal/not equal), thereby allowing the index method to accurately find index of the given value by comparing it to all those present values in the list.

Moreover, in the future, the possibility of defining 'default method implementations within a trait' can simplify custom structs’ ability to be used in a list by removing the explicit necessity for implementing both __eq__ and __ne__ methods in those structs. This is aimed at achieving a level of simplicity and ability in lists similar to what we can currently find in Python.

What is your motivation for this change?

This is an essential step forward for having more stable and Pythonic collection datatypes available in Mojo while narrowing down the differences between these two languages.

Any other details?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmojoIssues that are related to mojomojo-repoTag all issues with this label

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0