# Symbol in type signature?

**URL:** <https://discourse.julialang.org/t/symbol-in-type-signature/87887>\
**Category:** General Usage\
**Tags:** type, struct\
**Created:** [September 27, 2022, 7:02pm UTC](https://discourse.julialang.org/t/symbol-in-type-signature/87887 "2022-09-27T19:02:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [September 27, 2022, 7:02pm UTC](https://discourse.julialang.org/t/symbol-in-type-signature/87887/1 "2022-09-27T19:02:43Z")

</div>

The [Polynomial type](https://juliamath.github.io/Polynomials.jl/stable/polynomials/polynomial/#Polynomial-2) from the [Polynomials package](https://github.com/JuliaMath/Polynomials.jl/blob/master/src/polynomials/Polynomial.jl) has a symbol in its type signature that I don’t understand.

```julia
julia> typeof(Polynomial([1,2]))
Polynomial{Int64, :x}

julia> typeof(Polynomial([1,2], :s))
Polynomial{Int64, :s}

```

I am trying to use the Polynomial type inside my composite type, but it seems like I need to define the polynomial symbol ahead of time. Why? I wouldn’t think that changing the polynomial symbol would affect memory allocation for the compiler, so can I get away with leaving it abstract somehow? How and why would you define a type based on symbols instead of concrete types?

These error:

```julia
struct MyType
    polys::Vector{Polynomial}
end

```

```julia
struct MyType{T<:Number}
    polys::Vector{Polynomial{T, Symbol}}
end

```

This errors if the symbol changes.

```julia
struct MyType{T<:Number}
    polys::Vector{Polynomial{T, :s}}
end

```

This works, but I think will be slow since it is an abstract type:

```julia
struct MyType
    polys::Vector{<:Polynomial}
end

```

```julia
julia> isconcretetype(Vector{Polynomial{Int, :x}})
true

julia> isconcretetype(Vector{<:Polynomial})
false

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 27, 2022, 7:09pm UTC](https://discourse.julialang.org/t/symbol-in-type-signature/87887/2 "2022-09-27T19:09:00Z")

</div>

The variable name used to be a field of `Poly`, but it was changed in [V2.0.0 by jverzani · Pull Request #310 · JuliaMath/Polynomials.jl · GitHub](https://github.com/JuliaMath/Polynomials.jl/pull/310), which says:

> breaking changes, the main one is using the type system to hold the indeterminate rather than use a field to hold the indeterminate. The advantage is this plays better with Julia’s promotion mechanisms so matrices of polynomials requires much less fuss.

The question is, why do you care about the polynomial symbol in your application? Why not just call it `x` and be done with it? It seems like this mostly matters for multivariate polynomials?

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [September 27, 2022, 7:15pm UTC](https://discourse.julialang.org/t/symbol-in-type-signature/87887/3 "2022-09-27T19:15:51Z")

</div>

Fair point …  
In the function I was going to define next, the independent variable would be called `s`, but that seemed like a weird thing to hard code into the type container. Probably not worth the trouble though. I’ll just use `x`.
