# Undocumented "fields"?

**URL:** <https://discourse.julialang.org/t/undocumented-fields/33933>\
**Category:** General Usage\
**Created:** [January 29, 2020, 1:28pm UTC](https://discourse.julialang.org/t/undocumented-fields/33933 "2020-01-29T13:28:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [January 29, 2020, 1:28pm UTC](https://discourse.julialang.org/t/undocumented-fields/33933/1 "2020-01-29T13:28:48Z")

</div>

in [docs](https://docs.julialang.org/en/v1.3/manual/methods/#Design-Patterns-with-Parametric-Methods-1), I see the following:

```julia
eltype_wrong(::Type{A}) where {A<:AbstractArray} = A.parameters[1]

```

the `.parameters`, though I can guess what it is, it’s an **undocumented** “field” of type parameters. I wonder if there’s any **other hidden fields**? a small section about these “fields” in doc would be fine. thanks.

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [January 29, 2020, 1:51pm UTC](https://discourse.julialang.org/t/undocumented-fields/33933/2 "2020-01-29T13:51:25Z")

</div>

Those fields are implementation details, and the purpose of that example (note the name `eltype_wrong`) is to demonstrate that one should _not_ be using that sort of introspection, exactly because you cannot rely on the field even existing:

> One common mistake is to try and get the element-type by using introspection:
> 
> ```julia
> eltype_wrong(::Type{A}) where {A<:AbstractArray} = A.parameters[1]
> 
> ```
> 
> However, it is not hard to construct cases where this will fail:
> 
> ```julia
> struct BitVector <: AbstractArray{Bool, 1}; end
> 
> ```
> 
> Here we have created a type `BitVector` which has no parameters, but where the element-type is still fully specified, with `T` equal to `Bool` !

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [January 29, 2020, 1:53pm UTC](https://discourse.julialang.org/t/undocumented-fields/33933/3 "2020-01-29T13:53:12Z")

</div>

Also, you can overload these access too, check : `getfield / setfield! ` and `getproperty / setproperty! `.

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [January 29, 2020, 2:02pm UTC](https://discourse.julialang.org/t/undocumented-fields/33933/4 "2020-01-29T14:02:00Z")

</div>

oic. `propertynames(::Type, true)` gives the list of “hidden” fields:

```julia
julia> propertynames(Float64, true)
(:name, :super, :parameters, :types, :names, :instance, :layout, :size, :ninitialized, :uid, :abstract, :mutable, :hasfreetypevars, :isconcretetype, :isdispatchtuple, :isbitstype, :zeroinit, :isinlinealloc, :has_concrete_subtype, Symbol("llvm::StructType"), Symbol("llvm::DIType"))

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 30, 2020, 1:32pm UTC](https://discourse.julialang.org/t/undocumented-fields/33933/5 "2020-01-30T13:32:53Z")

</div>

They are not “hidden” — [see the devdocs](https://docs.julialang.org/en/v1.5-dev/devdocs/types/).

It is just bad style to rely on them outside `Base`, and unless you really need to. Usually you don’t, unless you are working on the language internals.
