-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Improve documentation of unary : #45426
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
Conversation
Unary `:` was poorly documented previously. The previous docs stated it would return a Symbol, but in fact also Expr objects and literal values can be returned from code quoting. See JuliaLang#43054
base/range.jl
Outdated
| `:expr` quotes `expr`, returning an abstract syntax tree (AST) of `expr`. | ||
| The AST may be of type `Expr`, `Symbol`, or a literal value. | ||
| Which of these three types are returned for any given expression is an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this sentence add anything useful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get what you mean, but part of what I found confusing in the original issue was what type was actually returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it is not really an implementation detail. It just depends on what you type. Like :3 will give you an integer and :foo a Symbol and it is not like that can just change with :foo suddenly giving you an Expr for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But e.g. :1111111111111111111 will give an integer while :11111111111111111111 will give an Expr. Would it be breaking to have the latter return an Int128 in the future? Probably not.
What can then be promised? Is it true that compound values will always return Expr and identifiers will always return Symbol, and literal values can return Expr or a literal?
The issue is that documenting it means it can't change. So, for example, :(1 === 1) cannot return true in the future. But maybe there is simply no way there will be a future desire for it to do that.
Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>
Unary
:was poorly documented previously. The previous docs stated it wouldreturn a Symbol, but in fact also Expr objects and literal values can be
returned from code quoting.
See #43054