Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++,comp.lang.c Subject: Re: lvalue assignment difference between C and C++ Date: Tue, 07 Feb 2023 11:08:23 -0800 Organization: None to speak of Lines: 28 Message-ID: <87edr1e1js.fsf@nosuchdomain.example.com> References: <0mvDL.68810$b7Kc.34465@fx39.iad> <87r0v2ecc0.fsf@nosuchdomain.example.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="4db3b9aae9ba641a7bd7c831368aa4f5"; logging-data="4032366"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18SEW19KxBIQ9L0eRwXq0d/" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:zHh2YzzbtgOynVW9nea+arjh3WY= sha1:23je+l8xMqC73QDolxM4vSMQhCQ= Xref: csiph.com comp.lang.c++:89019 comp.lang.c:169220 Muttley@dastardlyhq.com writes: > On Mon, 06 Feb 2023 13:03:11 -0800 > Keith Thompson wrote: [...] >>C's grammar is not trivial to parse, due to typedefs. A typedef >>effectively creates a context-specific keyword, which means the parser >>has to interact with the symbol table. (Historically, this is because >>typedefs were introduced relatively late in the evolution of C.) > > Could it not cheat and simply treat a typedef as a kind of macro? No, typedefs have scope, and a declaration in an inner scope can hide a typedef in an outer scope. #include int main(void) { typedef int Integer; { int Integer = 10; printf("Integer = %d\n", Integer); } // int Integer = 20; // would be a syntax error } -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */