Skip to content

Conversation

@jakobnissen
Copy link
Member

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
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
Member 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
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
Member 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.

Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
@ViralBShah ViralBShah added the docs This change adds or pertains to documentation label May 27, 2022
Co-authored-by: Valentin Churavy <vchuravy@users.noreply.github.com>
@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

docs This change adds or pertains to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants