Skip to content

Asymmetry between list.find and string/bytes.find/rfind #28303

@jabraham17

Description

@jabraham17

I noticed the following asymmetry between list.find and string/bytes.find/rfind

proc list.find(x: eltType, start: int=0, end: int=-1): int

string.find(pattern: string, indices: range(?) = this.byteIndices:range(byteIndex)): byteIndex
string.rfind(pattern: string, indices: range(?) = this.byteIndices:range(byteIndex)): byteIndex

bytes.find(pattern: bytes, indices: range(?) = this.indices) : int
bytes.rfind(pattern: bytes, indices: range(?) = this.indices) : int

I find it very odd and asymmetrical that list.find takes a start and end index, while string/bytes.find/rfind takes a range. The range argument feels much more Chapel-tastic and like a better interface; I think list.find should be updated to use that. Doing so is a breaking change, but I think its worth doing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions