Sujet : Re: do { quit; } else { }
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.cDate : 10. Apr 2025, 17:23:58
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250410091427.214@kylheku.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2025-04-10, Michael S <
already5chosen@yahoo.com> wrote:
In the message above Bart demonstrated that type of struct with
explicit tag depends not just on tag and fields, but also on
lexical scope.
In C, you cannot get the same type into two disjoint lexical
scope, unless they come from a common parent lexical scope.
The question simply does not arise:
{
struct foo { ... } x;
}
{
struct foo { ... } x;
}
If there is no previous declaration of "struct foo", these two structs
are in different universes; neither type is known outside of the
scope bubble in which it is defined.
No situation can arise in in which we would have to consider whether
the types are compatible.
Yes, struct tags are introduced into lexical scopes, and tags
introduced in different scopes are not related.
IMHO, instead of going into irrelevant details, it is much simpler to
postulate that all struct declarations within given translation unit
have different types.
No, because struct declarations can refer to existing previous
declarations by tag name.
These two are not different types:
struct foo;
struct foo { int x; };
We can probably say this: all occurrences of the "body braces"
of a struct definition are attached to distinct struct types,
in a program that requires no diagnostics.
>
If a "Simulation" object has a "gravity" member, do you conclude
that a given simulation has no gravity, because the constructor
omitted specifying it?
Simulation s = new Simulation(windSpeed = 35.7)
>
I am not quite understand how C++ is relevant.
That is pseudo-code, not C++. The purpose is to talk about the
difference between the syntax which creates an entity, and
the entity itself.
Are you an LLM?
-- TXR Programming Language: http://nongnu.org/txrCygnal: Cygwin Native Application Library: http://kylheku.com/cygnalMastodon: @Kazinator@mstdn.ca