Skip to content

Rename getindex and setindex! to operator form #42525

@timholy

Description

@timholy

A discussion on slack suggested that getindex is confusing and should perhaps be called getatindex (which is not quite as readable). But if we could write this in operator form

julia> Base.:(==)
== (generic function with 165 methods)

julia> Base.:([])
ERROR: syntax: invalid syntax "Base.[]" around REPL[2]:1
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

(it's good that it throws an error now, that means it's available) then we could add a custom array type and define

Base.:([])(A::MySpecialArray, i::Int) = ...

It would seem this doesn't even have to wait for Julia 2.0; that could be when we delete the older names.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions