Skip to content

Reorder [basic] before [lex] #2252

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

Open
zygoloid opened this issue Jul 7, 2018 · 12 comments
Open

Reorder [basic] before [lex] #2252

zygoloid opened this issue Jul 7, 2018 · 12 comments
Milestone

Comments

@zygoloid
Copy link
Member

zygoloid commented Jul 7, 2018

[basic] would make more sense if it appeared prior to [lex] rather than after. Conversely, [lex.separate] and [lex.phases] really belong in [basic], not [lex]. (We should also consider moving [cpp] to immediately after [lex] so that the top-level clauses are in a more logical phase-of-translation order, but keeping it in exile -- as an appendix of sorts -- has some merit too.)

@zygoloid zygoloid added this to the C++23 milestone Jul 7, 2018
@jensmaurer
Copy link
Member

Literally minutes after releasing a draft with the large C++20 renumbering applied do we come up with even further large-scale rearrangements.

@tkoeppe
Copy link
Contributor

tkoeppe commented Jul 8, 2018

Well, there's always force-pushing :-)

@jensmaurer
Copy link
Member

jensmaurer commented Jul 16, 2021

Maybe also move the preprocessor section near lex or merge both into a new "lexical processing" clause.

[basic] has some details that need to move later, e.g. allocation/deallocation function details should go to "Declarations".

Operator overloading [over.oper] should partially move to [expr] and to "Declarations".

@jensmaurer jensmaurer removed this from the C++23 milestone Feb 6, 2022
@jensmaurer jensmaurer added this to the C++26 milestone Feb 23, 2022
@jensmaurer
Copy link
Member

I have reservations about moving [basic] before [lex]; this needs more internal restructuring.

@AlisdairM
Copy link
Contributor

I was working on a PR/paper that would perform the suggested restructuring, and it quickly ended up redistributing most of [lex] across [basic] and [cpp]. In hindsight, the contents of [lex] truly should precede the contents of [basic].

One reorganisation that I believe did help was moving [cpp] to directly follow [lex], per the phases of translation, and then moving [modules] directly after the relocated [cpp] to put all the program composition and source transformation together, before starting on trying to interpret its actual contents. That involved also creating and deploying \firstcoreclause and \lastcoreclause to match \firstlibraryclause and \lastlibraryclause in config.tex.

@cor3ntin
Copy link
Contributor

lex.phases and lex.separate don't belong in lex, but lex really is better before basic so I don't see a good solution.
I really would be against splitting the rest of lex. lex is starting to be in good shape.

[modules] is in sort of a weird place - but it needs to be after [dcl] to make sense (or at least after basic). [cpp] does belong after [lex]. I think it was pushed to the end because well, it's [cpp].

We could do either of these somewhat targeted changes:

  • Move [modules] right before [cpp]
  • Move [cpp] right after [lex]
  • Move [cpp] right after [lex] and [modules] right after [basic] - giving us lex/cpp/basic/modules - which kind of make sense

The status quo does not prevent me to sleep, this would be a marginal improvement

@zygoloid
Copy link
Member Author

There has historically been resistance to moving [cpp] -- some have said they like having [cpp] as a neutral zone / buffer between core and library :) -- but I think logically [cpp] belongs towards the start of the standard, next to [lex] (actually in the middle of [lex] as it stands...).

There are some other issues in the presentation of [lex], mostly stemming from preprocessing token concerns getting mixed up with token concerns and phase 7 concerns. For example, most of [lex.ext] is talking about phase 7 things, and various other sections on literals talk about the meaning of expressions rather than anything to do with lexing.

If I were doing things over from scratch, I'd have a section describing phases 1-3 (and only phases 1-3), then a section describing phase 4, and I'd remove phases 5 and 6 (and instead specify that certain phase 7 grammar productions consume a sequence of string-literal tokens, not just one). And then a bunch of phase 7 stuff.

@AlisdairM
Copy link
Contributor

AlisdairM commented Jul 23, 2024

I have been working to address this issue in the background, and finally pushed my suggested refactoring in #7153.

This is NOT mergeable as it is based off something closer to N4981, the pre-St Louis draft. It is a vision of changes I would like to incrementally apply for the next mailing.

In particular, it gives up on merging parts of [lex] and [basic] as I could not find a satisfying merge, and instead focused on doing its best job on putting up front the parts that specify how to arrange source text to build a program.

The most obvious change is merging [cpp] into [lex], as both were small clauses the combined clause is closer to the average page count, but still low. I looked at merging the similarly small [modules], but did not find a good factoring at this time.

@AlisdairM
Copy link
Contributor

I have withdrawn the previous PR in favor of the more ambitious #7272 that completes the refactoring of [lex] to become a full clause on program construction. It comprises a sequence of many changes, some smaller, some larger, but the PR is intended for a design review of direction rather than an actual attempt to merge.

@AlisdairM
Copy link
Contributor

Now that the major clause cleaning has been done for C++26, should we defer this issue to C++29?

@jensmaurer jensmaurer modified the milestones: C++26, C++29 Oct 23, 2024
@jensmaurer
Copy link
Member

We're certainly not doing this for C++26.

@AlisdairM
Copy link
Contributor

https://wg21.link/cwg2670 might also relevant to any such reorganization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants