Evaluating literal expressions
Nobody has claimed this yet.
- Dominant language
- reStructuredText
- Stars
- 497
- Forks
- 41
- Avg merge
- 3h 52m
- Merged PRs (30d)
- 4
Description
The entire documentation for the evaluation of literal expresions is §6.2:3 (fls_wdpbg5xzgmwu), which says
The value of a literal expression is the value of the corresponding literal.
But the notion of the value of a literal isn't further defined.
(There's similar wording in in §6.2:2 (fls_w30su9x4q13r): "The type of a literal expression is the type of the corresponding literal." In that case, the type of each kind of literal is explicitly specified under "Legality Rules" in its subsection of §2.4 (fls_nrkd5wpi64oo).)
There are some statements listed under "Legality Rules" for some kinds of literal which I think are intended to be providing information about how a literal expression based on that kind of literal would be evaluated, but they aren't clearly tied in to the expressions chapter.
For example:
§2.4.4.1:2 (fls_nxqncu5yq4eu)
A binary literal is an integer literal in base 2.
§2.4.3:1 (fls_VKCW830CzhhN)
A c string literal is a literal that consists of multiple characters with an implicit 0x00 byte appended to it.
Similarly some of the paragraphs under "Syntax" may be relevant. For example §2.4.5:2 (fls_5v9gx22g5wPm) says a unicode escape
can represent any Unicode codepoint between U+00000 and U+10FFFF, inclusive, except Unicode surrogate codepoints, which exist between the range of U+D800 and U+DFFF, inclusive.
I think that may be trying to do double duty, both describing which forms are accepted and stating how a literal including such an escape is evaluated.
Information that as far as I can see isn't provided includes:
- how each kind of
AsciiEscapeis interpreted - how
StringContinuationis interpreted - how underscores in numeric literals are treated
- the rounding behaviour for floating-point literals
- that the characters in c string literals are encoded using utf-8
I think the "Literal expressions" chapter of the Reference has all the needed information. It defers to the standard library documentation for the interpretation of integer and floating-point literals; I don't know whether that would be appropriate for the FLS.
(The FLS is similar here to the state of the Reference in 2021, where that chapter only contained the grammar.)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with §6.2, "Literal expressions," and the literal subsections of §2.4, then compare the corresponding Literal expressions chapter in the Reference. Done means the FLS explicitly explains the listed literal-evaluation cases and clearly links or defers integer and floating-point interpretation where appropriate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100