# What is the interface for abstract types in Base?

**URL:** <https://discourse.julialang.org/t/what-is-the-interface-for-abstract-types-in-base/79729>\
**Category:** General Usage\
**Tags:** interface\
**Created:** [April 20, 2022, 9:26am UTC](https://discourse.julialang.org/t/what-is-the-interface-for-abstract-types-in-base/79729 "2022-04-20T09:26:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![melonedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/melonedo/32/15503_2.png) [@melonedo](https://discourse.julialang.org/u/melonedo)\
**Post date:** [April 20, 2022, 9:26am UTC](https://discourse.julialang.org/t/what-is-the-interface-for-abstract-types-in-base/79729/1 "2022-04-20T09:26:33Z")

</div>

Julia has a well-defined interface for `AbstractArray` related in the documentation, however, I have difficulty finding interface for:

- `AbstractString`: displaying it requires `ncodeunits(s::SomeString)`, `iterate(s::SomeString, i::Integer)`, are there more?
- `AbstractVector`: the size of vectors can be modified in Julia, I can do that with `push[first]!`, `pop[first]!`, etc, are there more methods to support?

---

<div class="post-metadata">

**Author:** ![Salmon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/salmon/32/22968_2.png) [@Salmon](https://discourse.julialang.org/u/Salmon)\
**Post date:** [April 20, 2022, 10:53am UTC](https://discourse.julialang.org/t/what-is-the-interface-for-abstract-types-in-base/79729/2 "2022-04-20T10:53:00Z")

</div>

Regarding your second example: I don’t know what Julia’s official definitions are here, but I should point out, that there are also sized arrays, like `StaticArrays` for instance.  
Consider this example:

```julia
julia> test!(x::AbstractVector) = push!(x,0)
test! (generic function with 1 method)
julia> using StaticArrays; test!(SVector(3,2,1))
ERROR: MethodError: no method matching resize!(::SVector{3, Int64}, ::Int64)

```

In general I guess this is one of the downsides of multiple dispatch, if you make the definition for an abstract type too loose, you end up with such kind of errors, on the other hand if you make the definitions too rigorous then you lose a lot of flexibility…

---

<div class="post-metadata">

**Author:** ![melonedo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/melonedo/32/15503_2.png) [@melonedo](https://discourse.julialang.org/u/melonedo)\
**Post date:** [April 20, 2022, 11:14am UTC](https://discourse.julialang.org/t/what-is-the-interface-for-abstract-types-in-base/79729/3 "2022-04-20T11:14:23Z")

</div>

Yes, resizing is certainly not universal, you don’t have to go that far, a lot of `AbstractVector` subtypes are just wrapper for external data:

```julia
A = [1,2,3]
B = unsafe_wrap(Array, pointer(A), 3)
push!(B, 4) # error

```
