C++ Logo


Advanced search

Re: Optional Semicolons

From: (wrong string) Åberg <haberg-1_at_[hidden]>
Date: Fri, 29 Apr 2022 10:07:05 +0200
> On 28 Apr 2022, at 20:10, Marios Staikopoulos via Std-Discussion <std-discussion_at_[hidden]> wrote:
> You are going from a state of: "Every statement must end in a semicolon" to "Some statement may not end in semicolons according to x,y,z rules". I do not see how that could make anything easier.

It might increase the lookahead the compiler must do: For example, the POSIX Yacc grammar used to admit omitting the semicolon ending the grammar rules, but then the yacc compiler does not know when the grammar rule has ended until reading the token following the next grammar rule name. This requires some trickery for the implementation. This missing semicolon feature has now been removed.

Some optional separators may be fine, like the last comma in an enum. It is followed a closing brace, so does not increase lookahead, while making user copy-and-paste easier.

Received on 2022-04-29 08:07:09