Path: csiph.com!news.mixmin.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Are there any conformant C compilers?
Date: Sun, 11 Sep 2022 21:22:42 -0700
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <86mtb5p6gd.fsf@linuxsc.com>
References: <871qswi3nc.fsf@nosuchdomain.example.com> <87wnaoghlj.fsf@nosuchdomain.example.com> <87sflahhkp.fsf@nosuchdomain.example.com> <87fsh9iz25.fsf@bsb.me.uk> <11d1020d-144d-4da0-88c1-3d56b4160c2an@googlegroups.com> <87pmgdh85z.fsf@bsb.me.uk> <878rn1h5lk.fsf@bsb.me.uk> <9586550c-6a4b-4a75-a10a-25f26e109b85n@googlegroups.com> <87tu5pfm0t.fsf@bsb.me.uk> <38331300-95c3-4499-aa89-062b82974309n@googlegroups.com> <87czccfyq0.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader01.eternal-september.org; posting-host="117318903d4b6f4d84a8201305c52178"; logging-data="2300153"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YhlVWqXCHZu+befVPmT/tu+Kc2w6gLzI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:NdBAr10Ek1F11timPEXZbfnRYpM= sha1:LxRxL2UUiNkA6LvNOzNzOk2LW3s=
Xref: csiph.com comp.lang.c:167628
Ben Bacarisse writes:
> David Brown writes:
>
>> On 03/09/2022 01:25, Thiago Adams wrote:
>>
>>> On Friday, September 2, 2022 at [...], Ben Bacarisse wrote:
>>>
>>>> Thiago Adams writes:
>>>>
>>>>> Maybe this sample will give the perspective that compound
>>>>> literal and string literals are the same.
>>>>
>>>> I don't see why you are posting this. What about the code do
>>>> you think I don't know or don't accept?
>>>
>>> I am just trying to understand if you or Bart are considering
>>> these compound literals different from string literal or
>>> numeric.
>>> We all understand how it works. I am just offering my
>>> perspective that for me they are all the same.
>>
>> Again, I think your wires are slightly crossed. Ben's point (and
>> he'll correct me if I'm wrong) is that you can write :
>
> Well it was Bart's point originally. I don't think there's any
> confusion about what's possible. I just think there been some
> wires crossed at some point.
>
>> void foo(char x, char y) {
>> printf("%s\n", (char []){ x, y, 0 });
>> }
>>
>> The second argument to printf is, in C terminology, a "compound
>> literal" - despite its value not being determined until runtime.
>
> I am pretty sure everyone in the thread knows all the facts!
>
> Thinking about it a bit more, the common factor with all literals is
> that they represent /anonymous/ values. Without compound literals you
> could not write a value of any aggregate type, other than char[].
The key difference is that "constants" are values, and "literals"
are objects.
That difference is a significant distinction, and justifies using
different words for the two kinds of syntactic elements.
> And if C were to get lambdas (anonymous functions), it might be
> reasonable to call them function literals. I don't know if that's
> a common usage, but it would explain how C uses the term.
Right. It never makes sense -- nor is it allowed -- to take the
address of a constant. It does make sense -- and furthermore is
allowed -- to take the address of a literal. Presumably lambdas,
aka anonymous functions, could have their addresses taken, which
makes "function literal" the natural terminology to use.