Article View: comp.lang.c
Article #2147Re: Iterators over slices and views and ranges analogs in C
From: Bonita Montero
Date: Thu, 03 Dec 2026 18:39
Date: Thu, 03 Dec 2026 18:39
114 lines
6503 bytes
6503 bytes
Better use C++ for what you want to do.
Am 03.12.2026 um 19:00 schrieb Ross Finlayson:
> Hello, good day, been trying to figure out an account of generics in C,
> that are specialized to type according to _Generic breaking out function
> overloads according to type, and for example breaking out
> sizes of arrays to "underloads", which uses a macro to ## concatenate
> for example after # stringifying identifiers, and making the
> controlling-expression of the generic then as with regards to varioously
> declared pointers of the types with the sizes matching to
> functions overloads/underloads with given lengths or otherwise
> parameters like enums, then with __auto_type and using pointers to
> fixed-size arrays so that array-decay-to-pointer preserves the type
> under the point for function resolution, then about how to figure out a
> way to make for generic sorts of containers, yet mostly about an adapter
> to "iterator" and with regards "views/ranges", so then that usually
> account of do/while and while/do and for in looping-constructs has
> something to do when data is considered to be of particular types
> not-necessarily contiguous their memory (storage according to C) as
> contiguous and as about the notion of memory as super-scalar or
> unbounded vis-a-vis the randomly accessible, secondarily.
>
>
>
> Of course, one may suggest to simply use a higher-level language
> where these sorts concepts as they are ("interfaces" usually in
> sth. like Java, "concepts" for example in C++ or as for template-types,
> with regards typename and the like, or templates in C++ about
> specializing the generics with the combined yet distinguished
> language and idiom of both C++ and Java, primarily C++ for its
> derivation from C and primarily Java for its own account of innovations
> later folded into C++, like for accounts of CharSequence vis-a-vis
> views/ranges and the like, yet here just pointing out that C++'s
> terms are C++'s and Java's are Java's and C's are C's, and other
> languages like Rust or Python just stick out as making things
> different to be different and not compatible like "enum" in Rust
> or whatever's "Pythonic" these days, that Rust and Python are
> considered second-cousins while C -> C++ -> Java is considered
> more of a line. (The language not necessarily the runtime.)
>
>
>
> /* pseudo-code: "overloading" */
>
> f_t _Generic( controlling_expression,
> t1_t: f_t1(),
> t2_t: f_t2(),
> default: static_assert /* omitting default is also static_assert */
> )
>
>
> /* pseudo-code: "underloading" */
>
> t1_t t1;
> t2_t t2;
>
>
> f_t _Generic( controlling_expression ## _t,
> t1_t: t(1),
> t2_t: t(2)
> )
>
>
>
> So, then what's sort of being figured is about how to go from array
> types, to variant, then while yet at compile-time, to dispatch over
> the introduced types, to result generics and their specialization,
> while resulting writing algorithms only to the "underloads", which
> for example C++ just generates many, many function-bodies, the idea
> being about how to generate 1 function-body "agnostic of type, yet,
> specialized to type", since the types are very simple and of only
> a few given types (the built-ins then tuples of fixed sizes).
>
>
>
> Then the account of iterators basically is about begin(), end(), next(),
> or for example since enumerations/vectors in Java like
> for next()/hasNext(), noticeably an opposite sort of account,
> then about what forever (rather, whatever) makes for being
> Iterable (interface in Java, concept in C++) about iterators and
> iterables, has that many, many times here have been written adapters
> to accessors to result generic access then about how to make that
> so for C in a nice sort of way, then also to result that a direct,
> natural reading surfaces the same code in C++ and for example
> idiomatically in C, C++, and Java, about the interfaces that
> the C libraries can provide, where the boundaries are according to C,
> since the process & thread they're according to the C runtime where
> it's hosted, usual accounts of code and loading & linking and so on,
> thus for the perceived requirement of iterators in C, according
> to functional signatures and a simple convention of name-spacing
> by function names, in C.
>
>
> Anyways I'd be curious if someone would point to something for
> example "oh forever since C++ was invented there was a an idiomatic
> C approach to iterators then later other standard sorts collections
> & containers, some national laboratory uses it for all the things
> and it's the same since forever", I'd be interested in that.
> Otherwise I'm looking at how to make one, figuring then
> it will be stable and standard and well-defined with the guarantees
> and so on, about many and various approaches basically to
> un-bounded, un-structured data as text, according to bounded structures,
> and iterators.
>
>
>
> Thanks for reading, it's invited your opinion.
>
>
>
>
>
>
Technical Details
Message-ID:
<11esd12$mfam$1@raubtier-asyl.eternal-september.org>Path:
mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mailReferences:
<-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!raubtier-asyl.eternal-september.org!.POSTED!not-for-mail From: Bonita Montero <Bonita.Montero@gmail.com> Newsgroups: comp.lang.c Subject: Re: Iterators over slices and views and ranges analogs in C Date: Thu, 3 Dec 2026 19:39:31 +0100 Organization: A noiseless patient Spider Lines: 114 Message-ID: <11esd12$mfam$1@raubtier-asyl.eternal-september.org> References: <-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 03 Dec 2026 18:39:31 +0000 (UTC) Injection-Info: raubtier-asyl.eternal-september.org; logging-data="736598"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vr7yyx/7SULe2KbwzBSed+AFn44qv44E="; posting-host="17cf8e9141147cb146fb1eeb71e228b0" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:8VLqZxZKy6QDds4VN3xsRC3UdRQ= sha256:k1vx6u/wJ5pZNsVlwmWPiNUNTx8fC3/UvfOvz3sKrGE= sha1:QNqQi/xk1LwR7oZSpZhD8dkG60k= sha256:/kDFH9dMdhFZ6jiYkNG4S1xJJR9vT7J+3XDM6EB2fd0= In-Reply-To: <-kGdnSzB4bWEM4z2nZ2dnZfqn_WdnZ2d@giganews.com> Content-Language: de-DE