I could see that being an alternative option to consider!
Personally I might favor |
for a few reasons, but I’m interested in hearing what you think:
- Has precedent in other modern languages for declaring type unions
- 3 fewer keystrokes (
\cup<tab>
vs<shift>\
) - Unicode characters can cause some issues due to their lack of built-in support on some platforms, whereas
|
is compatible with everything. (e.g., a phone keyboard, GitHub search, a new cloud server’s vim, etc). For an operator that could become widely used I think this is more sensitive of an issue. - I’m not sure what other people actually “read” when they read a signature, but
f(x::Union{Float32,Float64})
I would describe as taking “float32 or float64”, rather than a “union of float32 and float64”. (But this could totally be a personal thing)
The benefit I see is maybe less ambiguity in the mathematical meaning, since “\cup” has the correct meaning in math over sets (although perhaps incorrect in that concrete types can also be included in a union — which is more like an element), whereas in math, “|” is more like “given”. But I feel like “|” seems to have a different meaning in programming languages — one which actually is type unions…? What do you think?
I’m cognizant that syntax choices like this are purely based on popular opinion, though, since it’s what the majority finds intuitive/useful/etc. So this is why I’m very interested in seeing what people think.