Article View: comp.lang.c
Article #2197Re: Iterators over slices and views and ranges analogs in C
From: Ross Finlayson
Date: Fri, 04 Dec 2026 16:40
Date: Fri, 04 Dec 2026 16:40
114 lines
5724 bytes
5724 bytes
On 12/04/2026 08:23 AM, 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, it's a usual opinion that macros the line-continuation > line-endings are both un-agreeable and dis-agreeable. > > > "For each great saying, there's an equal and opposite great saying." > (Samuel Clemens or Mark Twain, also attributed to Apollo.) > > > > 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. > > (Saying "was" might still be "is".) > > > Thanks for writing, warm regards. > > Arguably, that which is inarguable is arguably arguable, including as not so. So, the agreeable and the arguable make for varying accounts of communication what's _agreed_ vis-a-vis what's _argued_, as that there are both internal & external or objective & subjective arguments & agreements, often enough about "open & closed arguments" and "standing | pending agreements", including for example to disagree, or, to "neither agree nor disagree: not argue". "So...", is a sort of statement of agreeing to argue to agree. These aren't "games of language", these are "accounts of the rules". (Rules are kinds of exceptions and exceptions are kinds of rules, ....) The, "inter-subjectivity" is a usual account, and for Grice's maxims as after "The Golden Rule" and so on.
Technical Details
Message-ID:
<yaOdnYaVFf9FcY_2nZ2dnZfqnPudnZ2d@giganews.com>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-3.nntp.ord.giganews.com!nntp.giganews.com!local-2.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mailReferences:
<-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!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-3.nntp.ord.giganews.com!nntp.giganews.com!local-2.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 04 Dec 2026 16:39:52 +0000 Subject: Re: Iterators over slices and views and ranges analogs in C Newsgroups: comp.lang.c 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> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Fri, 4 Dec 2026 08:40:03 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <0ESdnXrDxM2_dI_2nZ2dnZfqn_qdnZ2d@giganews.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <yaOdnYaVFf9FcY_2nZ2dnZfqnPudnZ2d@giganews.com> Lines: 114 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-N9RMk65scjSO+yoXh/K8jU62lF/dFVm+RT5Xa1eS+9Vq8tRigfMexmg3KxJAF3RPCFtpW+R9eEdTLJy!Xc7jyufGeizhgzMkXRFc/FlssWwpMBlRlFgbOn2s5fTR2d90l+zosiNdu4L2z60pp2viuMAnmV4= X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40