Article View: comp.lang.c
Article #2181Re: Iterators over slices and views and ranges analogs in C
From: Ross Finlayson
Date: Fri, 04 Dec 2026 15:03
Date: Fri, 04 Dec 2026 15:03
50 lines
3079 bytes
3079 bytes
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. 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), \ ) \ 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.
Technical Details
Message-ID:
<a8adndvZlvSgS4_2nZ2dnZfqn_WdnZ2d@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!Xl.tags.giganews.com!local-1.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>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!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 04 Dec 2026 15:03:25 +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> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Fri, 4 Dec 2026 07:03:33 -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: <11eudm8$1igc3$1@dont-email.me> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <a8adndvZlvSgS4_2nZ2dnZfqn_WdnZ2d@giganews.com> Lines: 50 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-6THrnDKrTGRkiA5z0TbcdNt4iKNXtV3Ln7ZC9uK+OF/TdExXCfzOAHPfSBy7ZRbMFjp22zPpzDT+Fy3!3vRiICKWmdiQ5rhCw4GPfyyeASHtfavFslZ1vV/3LqA0lz4CBQoRO6HjnFdVuzrA6to+adNFroQ= 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