-
Notifications
You must be signed in to change notification settings - Fork 533
Add Spec Glossary #1537
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
Add Spec Glossary #1537
Changes from 3 commits
dcdeb9c
e1fd482
f4ab575
8f464ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,5 +1,29 @@ | ||||||||||
# Glossary | ||||||||||
|
||||||||||
## Terms used in the Specification | ||||||||||
|
||||||||||
### Ill-formed Program | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Headings should be in sentence case. |
||||||||||
|
||||||||||
A Rust Program is ill-formed if it violates a statically set constraint placed on it by the language. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why some of these words are being capitalized. Also, I think this can be reworded to simplify a little.
Suggested change
I'm also trying to figure out, what is a "static constraint"? How would this contrast with a "dynamic constraint"? Would be possible to state it as "violates a rule of the language"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's to separate out from dynamic constraints that lead to undefined behaviour (such as dereferencing a null pointer). |
||||||||||
Unless otherwise statement explicitly an implementation shall issue an appropriate diagnostic for an ill-formed program and shall not translate such a program. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is some awkward wording here.
Suggested change
However, as an alternative, can this be stated as:
Suggested change
Although I don't know when we would ever state that it is not an error. Can you give an example? Is this referring to things like undefined-behavior? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See "No Diagnostic Required" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the proposed wording is a bit ambiguous here - you could argue it's always an error to have such a program (even if the constraint the program violated is one for which "no diagnostic is required"). |
||||||||||
|
||||||||||
#### No Diagnostic Required | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'm still struggling with understanding what this means. Is this trying to say that some rules may result in a warning, but otherwise isn't enforced? If so, I don't think we have yet agreed on an approach for how to document warnings. In general, we have avoided all warnings in the reference. There are a few exceptions when it is directly relevant to the language (like the diagnostic chapter), or when we have felt the warning is very important (like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lints are separate from this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'm still not understanding what this means. I don't see why there would be rules that we want to say "this may or may not compile". I'm trying to understand, is this related to undefined behavior? I see in the assembly chapter, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's basically super UB. With UB it's fine to have it in the program as long as it's not evaluated*. With IF-NDR, it's not fine to have it in the program. That particular list (in the original ASM chapter) is particularly bad, because it had quite a few things mixed together, including things that obviously are not fine in unevaluated code because they have potentially invalid global implications - for example, For the same reason, trying to put a function into |
||||||||||
|
||||||||||
When No Diagnostic is Required for a static constraint, the implementation may issue a diagnostic for the violation, and may translate the program. | ||||||||||
If such a program is succesfully translated, no constraints are placed on the result of executing the program. | ||||||||||
|
||||||||||
> [!NOTE] | ||||||||||
> The constraint which is modified by the phrase "No Diagnostic Required" may be defined implicitly, such as with the term "shall", rather than explicitly stating that the program is ill-formed. | ||||||||||
ehuss marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
|
||||||||||
> [!NOTE] | ||||||||||
> Such constraints are used only when it may be unreasonable or impossible to check the constraints statically, and where the result of violating the constraints makes it impossible to ensure the required behaviour of the program | ||||||||||
|
||||||||||
### Shall | ||||||||||
|
||||||||||
The word "shall" is a static constraint placed upon the program. A program that violates a constraint that uses "shall" is ill-formed. | ||||||||||
Comment on lines
+26
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't entirely object to specifying this, but I just want to call out that it seems unusual to do so. At least, I have not seen any other languages do that. Is there a precedent that shows this needing definition or way this could be confusing otherwise? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought C++ did but I checked and am incorrect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Ada standards do (since Ada 95; Ada 83 used "must"). See eg Ada 2012 §1.1.5:3. |
||||||||||
|
||||||||||
## Rust Specific Terms | ||||||||||
|
||||||||||
### Abstract syntax tree | ||||||||||
|
||||||||||
An ‘abstract syntax tree’, or ‘AST’, is an intermediate representation of | ||||||||||
|
@@ -105,6 +129,7 @@ are also considered local. Fundamental type constructors cannot [cover](#uncover | |||||||||
Any time the term "covered type" is used, | ||||||||||
the `T` in `&T`, `&mut T`, `Box<T>`, and `Pin<T>` is not considered covered. | ||||||||||
|
||||||||||
|
||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a stray newline? |
||||||||||
### Inhabited | ||||||||||
|
||||||||||
A type is inhabited if it has constructors and therefore can be instantiated. An inhabited type is | ||||||||||
|
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.
Can you say more about why this would be separated?
I think that generally we shouldn't need to separate this out. I don't think there should be terms here that aren't used in the specification (unless they are aliases for ones that are).
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'm back and forth on this.
The main thing I would put in the section would be prescriptive terms, rather than semantic terms (IE. terms used to express the requirements of the spec, not terms that refer to a construct). IE. a term like "function" wouldn't go in this section, but would go into the rest of the glossary.
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.
Might be something to discuss tomorrow.