-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unicode modifiers for adjoint operator #34507
Comments
Yes, I guess it is kind of weird that we allow category Lm (Letter, modifier) to start identifiers. We probably should have discussed that in #6805 😢. The same issue was also discussed in #28441. Unfortunately, it would be breaking to disallow identifiers starting with Lm now, and I'm skeptical that this counts as a "minor change" that we can do in 1.x. In any case, allowing Unicode modifiers for |
Duplicate of #28494? See also JuliaLang/LinearAlgebra.jl#410 where |
The unfortunate thing is that I don't see any non-breaking way to introduce this feature. Currently, even
Oh, I didn't discover that. Also seems to propose some of the changes made in #33683. The concrete proposal is a bit different though, so should I still leave this issue open? |
Any easy way to see if any packages are using this feature is to make it a syntax error and then run PkgEval. |
What would be the usual protocol for that? Should I open a PR here? |
It would be to make a [NO NOT MERGE] PR that causes the relevant syntax to be an error and then ask someone to trigger PkgEval. Might be easier to grep through all the registered packages though. |
Created a PR in #34549 if someone wants to trigger PkgEval on that. |
As mentioned in #34549 (comment), a survey of the fairly small number of packages which were broken by trying this out identified the following being used as postfix operators in category Lm:
But there was also the following in AbstractTensors
Currently it seems we allow a lot of category Sm to begin an identifier, for example: julia> ₋x = 1
1 So we'd also have trouble with parsing things like julia> :(x'⁻¹y)
:(x' * ⁻¹y) Maybe this isn't a problem but it's kind of annoying. |
What does triage think would be the best way forward here? Is the change in #34549 acceptable for a minor release, considering what PkgEval revealed? A probably less breaking alternative would be to only change the parsing of modifiers right after |
Just bumping this again. Is there any consensus forming? |
The original motivation for this is having a nicer syntax for
transpose
andconj
, where the most appropriate I could come up with wasM'ᵀ
andz'ᶜ
. Currently this would only be possible by special casingtranspose
andconj
at a parser level, but if #33683 was merged, one could extend the concept of Unicode modifiers for infix operators to'
very nicely. This would also be useful for packages like Zygote, which like to pun on'
as notation for taking the derivative, which could then export e.g.'ᴰ
instead.A problem is that currently,
a'ᵀb
is valid syntax foradjoint(a) * (ᵀb)
, which is quite unfortunate, since this is different from other infix operators like+
, where the modifier gets parsed as part of the operator, even if there is no whitespace in between. I therefore believe that parsing these as part of the operator will make for more consistency, but as this is technically breaking, it might be necessary to deprecate this syntax for one minor release first. Eventually it might make sense to disallow modifiers in front of variable names altogether, but that would be a separate issue.The text was updated successfully, but these errors were encountered: