# What interface bugs have you ran into in the ecosystem?

**URL:** <https://discourse.julialang.org/t/what-interface-bugs-have-you-ran-into-in-the-ecosystem/109001>\
**Category:** General Usage\
**Tags:** question\
**Created:** [January 19, 2024, 8:11am UTC](https://discourse.julialang.org/t/what-interface-bugs-have-you-ran-into-in-the-ecosystem/109001 "2024-01-19T08:11:23Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [January 23, 2024, 10:17am UTC](https://discourse.julialang.org/t/what-interface-bugs-have-you-ran-into-in-the-ecosystem/109001/18 "2024-01-23T10:17:09Z")

</div>

> [@sijo](#):
>
> But since indexing requires `getindex` , `firstindex` and `lastindex` I think conceptually at least it includes iteration. It’s definitely not orthogonal.

This is false. You can implement methods in the indexable interface without implementing any in the iterable interface, and vice versa. An indexable can also lack `firstindex` and `lastindex` because it has no semantic beginning and end, e.g. `LinearAlgebra.I`. Obviously without a start, `I` is not iterable. Immutable indexables like `I` also lack `setindex!`. The `AbstractArray` interface specifically includes both indexing and iteration; that doesn’t imply indexing and iteration are intertwined in general.

> [@sijo](#):
>
> we could define `last` for `Iterable` but not for `Indexable` since the semantics of `last` are related to iteration.

This is also somewhat false, there is a fallback `last(coll)` method based on `lastindex` and a fallback `last(itr, n::Integer)` method based on iteration. More specific methods of either arity can be defined however you like. For example, the non-indexable and infinite iterator from `Iterators.cycle` implements `last(it::Cycle)` to fall back to `last` of the wrapped instance.

An aside, `last(itr, n::Integer)` depends on `Iterators.reverse`, which isn’t in the leading table of methods but is mentioned at the very end of the iteration interface docs. That’ll be the faster way to do `last` for iterables than iterating from the start, and evidently from `Cycle` does not require a finite `length`.

> [@sijo](#):
>
> It’s done in Go

Go [eschews](https://go.dev/doc/faq#overloading) method overloading and multimethods to allow its type system and dispatching to even work. This is a fundamental design tradeoff.

> [@sijo](#):
>
> imperative dispatch based on reflection

I have no earthly clue what this could mean. The reflection I mentioned has nothing to do with how I would dispatch my methods, it would, for example, check `last(::MyType)` and tell me to implement `lastindex(::MyType)`, or check `last(::MyType(), ::Int)` and tell me to implement `Iterators.reverse(::MyType)`. Ideally it’d save me the trouble of looking up interface documentation and source code.

---

_[View the full topic](https://discourse.julialang.org/t/what-interface-bugs-have-you-ran-into-in-the-ecosystem/109001)._
