C++ Logo


Advanced search

Re: [wg14/wg21 liaison] labels

From: Bjarne Stroustrup <bjarne_at_[hidden]>
Date: Wed, 12 Aug 2020 09:04:44 +0200
Sort of. The basic idea was simply to allow a declaration wherever a
statement was allowed. The reason for that was to allow users to declare
variables only when needed and where an meaningful initializer was
available. Any restrictions added were to address language-technical
technical problems. The reason was never primarily to do with grammar

On 8/12/2020 12:35 AM, Richard Smith wrote:
> This makes sense. Someone made the decision that declarations
> are statements. I assume the purpose was to allow labels to be
> placed in front of declarations.
> I don't know (maybe Bjarne can tell us) but I doubt that was the
> reason. Rather, I suspect that when C++ started to allow declarations
> to appear anywhere in a compound-statement, modelling declarations as
> a kind of statement was the simplest way to get that effect. And it
> makes sense and simplifies the model to only have one kind of thing
> that can appear in a compound-statement.

Received on 2020-08-12 02:08:11