Composite types and their subtypes

You’re correct that the answer is no. See: Types · The Julia Language

Your first type has a type parameter with the name Float64 which does absolutely nothing. The fields x and y can still be of any type. Moreover, the fact that the type parameter has a name which is the same as an existing type (Float64) is totally irrelevant.

Your second type, on the other hand, actually restricts the x and y fields to be of type Float64.

To implement a parametric Point type, you want something like this:

mutable struct Point{T}
  x::T 
  y::T 
end

which creates a struct with a parameter named T and two fields which must both be of that same type T.

2 Likes