-
-
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
Clarify what "no program" means in egal docs #54887
base: master
Are you sure you want to change the base?
Conversation
While the statement in the docstring is correct, it relies on an idiosyncratic definition of "no program", referencing Julia's semantics. Occasionally, a Julia user will point out that they can actually write a program that can distinguish two egal values. This commit clarifies that while such programs may work, they rely on going outside the language's semantics.
# Extended help | ||
It might be possible to construct a program that is actually able to distinguish | ||
two egal values. For example, one could heap-allocate two integers, | ||
then compare the value of a pointer pointing to their heap address. |
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 am not sure how to realize that example with "heap allocated integers".
How about talking about strings instead, were this is quite easy to demonstrate in practice? E.g.
julia> a = "x" ; b = "x" ; a === b
true
julia> pointer_from_objref.([a,b])
2-element Vector{Ptr{Nothing}}:
Ptr{Nothing} @0x000000010cf60748
Ptr{Nothing} @0x000000010cf60780
|
||
# Extended help | ||
It might be possible to construct a program that is actually able to distinguish | ||
two egal values. For example, one could heap-allocate two integers, |
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.
that is actually able to distinguish two egal values
I think this is not an idea formulation because the program doesn't actually distinguish two egal values.
two egal values. For example, one could heap-allocate two integers, | ||
then compare the value of a pointer pointing to their heap address. | ||
However, all such programs rely on observing behaviour outside Julia's allowed | ||
semantics, and so happen to work due to implementation details and/or triggering |
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.
Reading this my first thought was: What are "Julia's allowed semantics", and where can I find out more.
I.e.: To me this doesn't clarify much. Mainly I am left with this message: "You can't distinguish egal values by the rules, which I am not telling you, just so you know: if you found a way it is cheating and you should not rely on it in any way."
But is that really helpful? Honest open question, I don't know. Since you opened the PR, presumably you feel this text (or at least parts of it) would have been helpful for you to know when you run into this?
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.
That's a fair summary. On the other hand, the current message is "you can't distinguish egal values", which is just false - you absolutely can, e.g. by comparing pointers to strings, as you did in the example above.
When I first read that docstring I tried the same thing as was confused - I then had to ask on Slack what was up with that. Since then, I've seen twice that people have asked the same question - those have been lost to the slack hole, but searching for the docstring of ===
on Discourse brings this post up, with the same question.
I.e. as I see it, the confusing thing is that the claim "you can't distinguish these two values with any program" appears superficially simple, but the statement's truth relies on complex language semantics which almost no user knows about.
So, I think either that statement should be removed from the docs, or else it should be properly explained what it means.
I would prefer explaining it, and possibly linking to the devdocs on UB which explains it in more detail.
While the statement in the docstring is correct, it relies on an idiosyncratic definition of "no program", referencing Julia's semantics. Occasionally, a Julia user will point out that they can actually write a program that can distinguish two egal values.
This commit clarifies that while such programs may work, they rely on going outside the language's semantics.