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

Improve documentation of unary : #45426

Merged
merged 4 commits into from
Jun 1, 2022
Merged

Conversation

jakobnissen
Copy link
Contributor

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 #43054

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
Copy link
Sponsor Member

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?

Copy link
Contributor Author

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.

Copy link
Sponsor Member

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.

Copy link
Contributor Author

@jakobnissen jakobnissen Jun 1, 2022

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.

base/range.jl Outdated Show resolved Hide resolved
base/docs/basedocs.jl Outdated Show resolved Hide resolved
Co-authored-by: Shuhei Kadowaki <[email protected]>
@ViralBShah ViralBShah added the domain:docs This change adds or pertains to documentation label May 27, 2022
base/docs/basedocs.jl Outdated Show resolved Hide resolved
Co-authored-by: Valentin Churavy <[email protected]>
@aviatesk aviatesk merged commit 8373146 into JuliaLang:master Jun 1, 2022
@jakobnissen jakobnissen deleted the colondocs branch June 1, 2022 07:28
LilithHafner added a commit that referenced this pull request Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:docs This change adds or pertains to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants