Skip to content
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

Allow operator suffixes to the postfix apostrophe #28494

Closed
perrutquist opened this issue Aug 7, 2018 · 3 comments
Closed

Allow operator suffixes to the postfix apostrophe #28494

perrutquist opened this issue Aug 7, 2018 · 3 comments

Comments

@perrutquist
Copy link
Contributor

perrutquist commented Aug 7, 2018

Since #22089 it is possible to add suffixes to existing binary operators in order to create entirely new ones.

If it were possible to add suffixes to the postfix ' operator as well, then that would make it possible for the user to create an arbitrary number of new postfix operators. For example, it would make it possible to make A'ᵀ the transpose of A.

See #21037 for the beginning of this discussion. Here's a brief summary as best as I've understood: The original proposal was to map x' to the function call '(x), and then allow suffixes on that function name, but this is not possible. The first character of an identifier cannot be ', because ' is already used to introduce character literals. On the other hand, using a function name like apostrophe can lead to problems similar to #25947. That problem can be avoided by mapping to Base.apostrophe instead of using the local scope.

@perrutquist
Copy link
Contributor Author

perrutquist commented Aug 14, 2018

I believe that it would be possible to shoehorn in a ' identifier by allowing it
in contexts where a character literal is not allowed. The most important
use cases: function ', import ', and export ' would work, because a
character literal cannot follow those keywords.

In other contexts, one would need something convoluted like eval(Symbol("'")).
For example, the Base module might have const apostrophe = eval(Symbol("'")),
so that Base.apostrophe(::Foo) = bar, would be equivalent to
import Base: '; function '(::Foo); bar; end'.
But these would be rare cases, that normal users need not worry about.

@simeonschaub
Copy link
Member

Should be fixed by #37247

@stevengj
Copy link
Member

Closed by #37247

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants