Adding \mid
to the parser and setting its precedence higher than ::
as an experimental feature
#52756
Labels
parser
Language parsing and surface syntax
speculative
Whether the change will be implemented is speculative
unicode
Related to unicode characters and encodings
There have been long discussions on GitHub and recently on Discourse on making an operator like
|
as syntax sugar for union type, which is driven by recent precedents in python, typescript, and scala. The consensus has come that it needs to be explored in the package first to see if there is any serious demand for this feature. On top of that, it requires punning the meaning of|
and preferably changing its precedence over::
, which seems burdening.Currently, a close sibling,
\mid
, is unregistered:This looks like a perfect opportunity to put it in a parser with precedence higher than
::
, enabling us to explore its usefulness as a union syntax in a package. The burden that it is a non-ASCII character can be viewed as a benefit as it allows us to find out if the higher precedence for\mid
is more useful than|
in spite of additional costs. This, perhaps in the future, could help to guide the decision whetherJulia 2.0
needs|
as a higher precedence operator than::
. A similar analysis can already be done with a macro; however, this is significantly more intrusive and can make other useful macros break when used in combination.If this feature request is fulfilled, then it would be possible to add the following sugar with a package:
This has the benefit that it is easier to add optionality later by putting a cursor in one place vs putting it in two as it is now when it goes from
Signature
->Union{Signature, Nothing}
.The text was updated successfully, but these errors were encountered: