Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Top 10 most common hard skills listed on resumes...
Date: Sat, 31 Aug 2024 15:10:07 -0700
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <86seuktkcg.fsf@linuxsc.com>
References: <874j75zftu.fsf@bsb.me.uk> <87mskwy9t1.fsf@bsb.me.uk> <875xrkxlgo.fsf@bsb.me.uk> <87o75bwlp8.fsf@bsb.me.uk> <871q27weeh.fsf@bsb.me.uk> <20240829083200.195@kylheku.com> <87v7zjuyd8.fsf@bsb.me.uk> <20240829084851.962@kylheku.com> <87mskvuxe9.fsf@bsb.me.uk> <875xrivrg0.fsf@bsb.me.uk> <20240829191404.887@kylheku.com> <86cylqw2f8.fsf@linuxsc.com> <871q2568vl.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 01 Sep 2024 00:10:07 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="1ccc4d5fef9c2c82c9c978d9286151e6"; logging-data="1240558"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19I7476rlyunOr9xmTsMGEVCB79I3Rlxmc="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:ynVyIKRtDtEiNdf6hx4p2AIJkl8= sha1:4lPCx8fus5KuIrT8+au9MU1iNEY=
Xref: csiph.com comp.lang.c:388059
Bart writes:
> On 30/08/2024 21:41, Keith Thompson wrote:
>
>> Tim Rentsch writes:
>>
>>> Kaz Kylheku <643-408-1753@kylheku.com> writes:
>>>
>>>> On 2024-08-29, Ben Bacarisse wrote:
>>>>
>>>>> Bart 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.
>
> AFAICT both terms are parsed the same way.
>
> Given this:
>
> x + y = z;
> (x + y) = z;
>
> My compiler produces the same AST for the LHS of '=' in both
> cases.
To understand why they are different, try drawing parse trees
rather than abstract syntax trees.
https://en.wikipedia.org/wiki/Parse_tree