Description
@jakebolewski had this very good idea today.
Our tuple types are currently quite ugly since they are not distinguished from tuple values. This causes various problems in the system, such as whether to treat ()
as a type. We also need to specialize tuple representations (e.g. storing (Float64,Float64)
as compactly as a Complex128
), which means tuple types will need to contain extra layout information that tuple values do not have. This would also eliminate the need for a fancy predicate to test whether some tuple is a type.
It would be quite easy to use Union{...}
for union types, and then all types would be constructed with curly braces 👍.
This change also makes it easy to use (x, y...)
for splatting in tuple construction (#4869), and {Int...}
for varargs types.
All current uses of { }
can be replaced with Any[ ]
or (Any=>Any)[ ]
, so that syntax is effectively up for grabs. The wastefulness of the current { }
has been discussed elsewhere. I admit this proposal feels slightly wasteful as well, but it could be worth it for solving various problems in the type system and making type syntax highly consistent. On the whole, I am in favor of this idea.