🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #2199

Re: Iterators over slices and views and ranges analogs in C

#2199
From: David Brown
Date: Fri, 04 Dec 2026 16:54
119 lines
6419 bytes
On 04/12/2026 17:23, Ross Finlayson wrote:
> On 12/04/2026 08:14 AM, David Brown wrote:
>> On 04/12/2026 16:03, Ross Finlayson wrote:
>>> On 12/04/2026 05:03 AM, bartc wrote:
>>>> On 04/12/2026 12:45, Bonita Montero wrote:
>>>>> Am 04.12.2026 um 13:07 schrieb bartc:
>>>>>
>>>>>>   #define typename(x) (_Generic((x),\
>>>>>>       int:                   "int",\
>>>>>>       unsigned int:          "unsigned int",\
>>>>>>       const int:             "const int",\
>>>>>>       default:               "other"))
>>>>> Compared to C++ generics this really, really sucks !
>>>>>
>>>>
>>>> How would you do typename(x) in C++ then?
>>>>
>>>> That is, return the type of expression 'x' as a string (in some
>>>> canonical form).
>>>>
>>>> This is not really generics, but reflection.
>>>>
>>>> In my language it would be:
>>>>
>>>>      'x.typestr'
>>>>
>>>> (With 'x.type' returning a unique ordinal for the type, which can be
>>>> used for comparisons etc.)
>>>>
>>>>
>>>
>>> Methinks the standard says that according to _Generic construct that
>>> cv-qualified types are distinct types with regards generic (_Generic,
>>> the "generic" construct in C.
>>>
>>
>> No.  Please read the other posts, or the C standards, or a decent
>> reference like <https://cppreference.com/c/language/generic>.
>>
>>>
>>> About the pointer decay (i.e., array-decay-to-pointer), and fixed length
>>> arrays, idea seems to be to pass a pointer to the array as
>>> controlling-expression.
>>>
>>> _Generic( &x, \
>>> *(int[64]): f_64(x), \
>>> *(int[128]): f_128(x), \
>>> ) \
>>
>> That should work, yes.  Test it on godbolt.org.
>>
>> Alternatively you can wrap your fixed-length arrays in structs.
>>
>>>
>>> Then the idea is that pointer-decay of a pointer to a fixed-length array
>>> yet maintains the fixed-length type.
>>>
>>> Agreeably, the line-continuation line-endings is macro-y and jarring
>>> to both readers and parsers.
>>>
>> The word "agreeably" does not mean what you think it means.  Your Humpty
>> Dumpty approach to language makes your posts jarring to readers.
>>
>>
> 
> 
> "Agreeably" means at least two things, it may mean "Agreeably, as in
> I'm being agreeable...", or "Agreeably, this is agreeable", then with
> regards to what "agreeable" is, it has several meanings, like "this is
> agreeable in the sense of aesthetic judgment" or "this is agreeable
> and you can take it or leave it" meaning some do and some don't.

"Agreeably" means "pleasantly" or "happily", usually with a connotation 
of surprise.  It is related to, but different from "agreeable".  Neither 
word would be appropriate to how you are trying to use it.

When you write "Agreeably, macros with line continuation characters are 
jarring", you really mean "I agree that macros with line continuation 
characters are jarring" or "I think many people would agree that macros 
with line continuation characters are jarring".  It would, of course, be 
silly to say "I agree that..." when nobody else has given such an 
opinion.  But if you mean the second form - "I think that many people 
would agree that ...", then write that.

The actual meaning of what you wrote is that you think it is 
surprisingly pleasant that macros with line continuation characters are 
jarring.  You use the word regularly, and invariably do so incorrectly.

I can't teach you how to express yourself better.  All I can do is tell 
you that it is far harder for people to give you help, advice and 
corrections in your C understanding and coding when you can't ask a 
clear question, and when your misuse of the language is so dominant in 
your posts.

(If you want to discuss more about the word "agreeably", do so in a 
forum on language usage - or ask your friendly neighbourhood AI to 
explain it.  I've wasted too many words on this already.)

> 
> 
> 
> About the cv-qualified and those being considered separate types,
> yes that surprises me I was under the impression that the _Generic
> construct distinguishes among cv- and non-cv-qualified types.

Then you have now learned something new about C, and my effort was not 
entirely wasted!

> 
> (Saying "was" might still be "is".)
> 
Change it to "is".  If you don't trust one random poster on the internet 
(and that's a good attitude), look it up.  I have given you a solid 
reference site, and you can easily find a copy of the C standards.  I 
also recommend playing around on godbolt.org to look at generated code 
using compilers written by people who understand these details far 
better than most.

Technical Details
Message-ID: <11eur90$1pnn7$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com> <11esd12$mfam$1@raubtier-asyl.eternal-september.org> <11et39b$rj55$1@news.xmission.com> <11ett3b$1a41p$1@dont-email.me> <11euadh$1gp4t$1@dont-email.me> <11euckd$1ht9i$1@raubtier-asyl.eternal-september.org> <11eudm8$1igc3$1@dont-email.me> <a8adndvZlvSgS4_2nZ2dnZfqn_WdnZ2d@giganews.com> <11euot5$1ogcm$1@dont-email.me> <0ESdnXrDxM2_dI_2nZ2dnZfqn_qdnZ2d@giganews.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.hispagatos.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: Iterators over slices and views and ranges analogs in C
Date: Fri, 4 Dec 2026 17:54:55 +0100
Organization: A noiseless patient Spider
Lines: 119
Message-ID: <11eur90$1pnn7$1@dont-email.me>
References: <-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com>
 <11esd12$mfam$1@raubtier-asyl.eternal-september.org>
 <11et39b$rj55$1@news.xmission.com> <11ett3b$1a41p$1@dont-email.me>
 <11euadh$1gp4t$1@dont-email.me>
 <11euckd$1ht9i$1@raubtier-asyl.eternal-september.org>
 <11eudm8$1igc3$1@dont-email.me>
 <a8adndvZlvSgS4_2nZ2dnZfqn_WdnZ2d@giganews.com>
 <11euot5$1ogcm$1@dont-email.me>
 <0ESdnXrDxM2_dI_2nZ2dnZfqn_qdnZ2d@giganews.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 04 Dec 2026 16:54:56 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1892071"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19OiT2ADXPfsT4EsZSHQml7AcqxO+uEdZE="; posting-host="f8d429fc41b298b14a9203a87d5618c6"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:UeSziZjRZiwi1FPYkmiySJ749AU= sha256:ke5Af42fhLrGeGDSkvWT4r8M/JWy87x0FoL3vp1f1MM=
	sha1:HLND0dbS6ZlmMKhCeFTSCNmbCq4= sha256:lr+qFa+AmUTlAG+ItcI4K7cfheMJNXhOy63rVoboNBE=
In-Reply-To: <0ESdnXrDxM2_dI_2nZ2dnZfqn_qdnZ2d@giganews.com>
Content-Language: en-GB, nb-NO