Deutsch English Français Italiano |
<871q2568vl.fsf@nosuchdomain.example.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson <Keith.S.Thompson+u@gmail.com> Newsgroups: comp.lang.c Subject: Re: Top 10 most common hard skills listed on resumes... Date: Fri, 30 Aug 2024 13:41:50 -0700 Organization: None to speak of Lines: 47 Message-ID: <871q2568vl.fsf@nosuchdomain.example.com> References: <vab101$3er$1@reader1.panix.com> <vahngt$2dtm9$1@dont-email.me> <87r0abzcsj.fsf@bsb.me.uk> <vai1ec$2fns2$1@dont-email.me> <874j75zftu.fsf@bsb.me.uk> <valrj7$367a8$2@dont-email.me> <87mskwy9t1.fsf@bsb.me.uk> <vanq4h$3iieb$1@dont-email.me> <875xrkxlgo.fsf@bsb.me.uk> <vapitn$3u1ub$1@dont-email.me> <87o75bwlp8.fsf@bsb.me.uk> <vaps06$3vg8l$1@dont-email.me> <871q27weeh.fsf@bsb.me.uk> <20240829083200.195@kylheku.com> <87v7zjuyd8.fsf@bsb.me.uk> <20240829084851.962@kylheku.com> <87mskvuxe9.fsf@bsb.me.uk> <vaq9tu$1te8$1@dont-email.me> <875xrivrg0.fsf@bsb.me.uk> <20240829191404.887@kylheku.com> <86cylqw2f8.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Fri, 30 Aug 2024 22:41:54 +0200 (CEST) Injection-Info: dont-email.me; posting-host="06fc674f2ef62846f0d6137618397abc"; logging-data="687034"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+abURtbjOoEdDwuEqQ6C1P" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:G45M14ZF+DVivuAetxsgZoQ0gvM= sha1:ed0f3mFPYb74USWqFvBARgr4wwY= Bytes: 3696 Tim Rentsch <tr.17687@z991.linuxsc.com> writes: > Kaz Kylheku <643-408-1753@kylheku.com> writes: >> On 2024-08-29, Ben Bacarisse <ben@bsb.me.uk> wrote: >>> Bart <bc@freeuk.com> writes: >>>> I think that these (with x, y having compatible scalar types): >>>> >>>> x + 1 = y; >>>> (x + 1) = y; // in case above was parsed differently >>>> >>>> are both valid syntax in C. It will fail for a different reason: >>>> an '+' term is not a valid lvalue. >>> >>> The compiler must tell you that neither is valid C. That's >>> because what is required on each side of assignment is not >>> exactly the same thing. It's a distraction to argue about why >>> each is not valid C as both have errors that require diagnostic >>> at compile time. >> >> Bart is only saying that it's valid syntax, not that it's valid C. >> >> According to the ISO C syntax (not taking into account contraints, >> which are not syntax) that view is justified. > > The second line is syntactically well-formed. The first line is > not. Right, because the LHS of an assignment is a unary-expression. `(x + 1)` can be parsed as a unary-expression, but `x + 1` cannot. However, the compilers I've tried produce the same diagnostic (not a syntax error message) for both. Probably they use a tweaked grammar that allows more a general expression as the LHS of an assignment, and catch errors later in semantic analysis, for the purpose of producing diagnostics that are easier to understand. It's obvious that in `x + 1 = y`, the programmer (probably) intended `x + 1` to be the LHS of an assignment. These compilers (I tried gcc, clang, and tcc) are clever enough to recognize that. For most programmers (in my opinion and apparently in the opinions of those compiler developers), the fact that the two intended assignments are invalid for different technical reasons is less important than understanding that they're invalid, and in a way that helps the programmer figure out how to correct them. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */