🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1631

Re: Inversion-of-control and dependency-injection in C

#1631
From: Ross Finlayson
Date: Wed, 18 Nov 2026 14:01
149 lines
8774 bytes
On 11/18/2026 05:18 AM, bartc wrote:
> On 18/11/2026 12:13, Ross Finlayson wrote:
>> On 11/13/2026 08:54 AM, David Brown wrote:
>>> His posts are not written by AI - no AI writes that badly.  And it is
>>> not so void of meaning and grammar that it is randomly generated.  Ross
>>> has written posts in this style for many years in several Usenet groups.
>>>   I find it hard to believe that someone would spend so much time and
>>> effort for a joke.
>>>
>>
>> Then, in another thread, bringing it back here:
>>
>>  >> Here then for example, what I'm trying to figure out is basically
>>  >> how to make for C what's in C++ without being in C++ that's yet
>>  >> readily adaptable for calling and being called from and into C++
>>  >> from C. Like, for example, "sequence" or "iter", and "lister"
>>  >> and the like, then for something like "C11 _Generic", making accounts
>>  >> of generics the types in C vis-a-vis the polymorphic class model
>>  >> in C++, about "sized" or accounts like "characteristics" of access
>>  >> of arrays, pointer-offsets, lists, otherwise the usual things,
>>  >> "holders", "getters and setters", then about "libraries" and
>>  >> "components", after things like "success_t, error_t, and return_t,
>>  >> for context_t", definitions of the patterns, that would be generally
>>  >> suitable for writing libraries in C and having them callable and
>>  >> calling to and from C++, these are the kinds of things I'm liking
>>  >> to figure out.
>>  >>
>>  >>
>>  >> Like for example about how to pass an allocator into C, or making
>>  >> access of ctx_new/ctx_del or ctx_init/ctx_fini, those being about
>>  >> storage or lifetime and ownership and responsibility, then for
>>  >> things like "emit_log" and "emit_metric" and "emit_dump", these
>>  >> are the kinds of things that later always live in any sort of
>>  >> application framework, for making good-style.
>>  >>
>>  >
>>  > Why not just write :
>>  >
>>  > """
>>  > How do I write C++ code in C?
>>  > """
>>  >
>>  > The answer then would be, you don't.  Write C++ code in C++.  Write C
>>  > code in C.
>>  >
>>
>>
>> Here the points under consideration are that C++ has some relevant
>> constructs that to use the same patterns in C, then to make for
>> the _interoperability_, has for example that libraries of most
>> any usual sort result their symbols, those being of C, or as after
>> name-mangling (a convention of expressing the namespaces and constructs
>> encoding the names/symbols as C defines for what C++ models,
>> name-mangling, where "the mangle" is a steam-press for the ironing
>> of sheets, where the common meaning is "fold, spindle, and mutilate"),
>> there's that "writing C++ in C", is to make it adapt-able.
>
> That paragraph should be taken out and shot.
>
> Together with most other gibberish you write.
>
> Are you asking a question here? Why are you posting this; what response
> are you after?
>
> Or maybe you enjoy regurgitating random facts in as incomprehensible a
> manner as possible.
>
> Or is your aim just to provoke reactions like this?
>
>>
>> Then, other accounts involve the system, for example malloc/free,
>> vis-a-vis, allocators, and that C++'s account of new/delete,
>> has also an account of pretty much every constructor allowing
>> the passing of an allocator, for example about free-lists/arenas/slabs,
>> about how to make a _pattern_ so that either the library interface
>> signature has function-pointers for acquire-release, or, for example,
>> there's a convention where each process/thread has a global-variable
>> (called thread-local in a thread, global to the thread) with function
>> pointers for acquire/release.
>>
>> It's similar with stdio, or for example loggers, usually considered
>> "static" (or extern) to the process to result a global entry-point
>> for the rest of the routine, or, what makes for that it gets passed
>> to every library-function or installed in the context passsed to every
>> library function, about what aren't "classes" and "instances" like in
>> C++ which is defined in the language, _yet so model those_, why it's a
>> thing.
>>
>> Other examples of accounts for example make for list-adapters or
>> iterators or accounts of sequences then about treating arrays and
>> lists as the same (while they have different characteristics of
>> access, the "access-patternry"), then for example about associative
>> arrays and sets and the like then into traversals for trees and graphs
>> and the like, where for example many "loosely-typed" languages of the
>> day (like JavaScript, Python, ...) have that's _default_ with the
>> "slots" the associative-array, vis-a-vis something like "the shell
>> language" and accounts of attributes, and behaviors for arrays and
>> associative-arrays, those being considered general. So, the idea is
>> that something like C11 has something like "_Generic" keyword to employ,
>> that instead of writing to a concrete implementation of
>> an array or list, instead to write to the _adapters_ of these,
>> in C, which can be more direct for C++, with C++'s great account of,
>> "Abstraction", for the abstract and the concrete, and that anything's
>> both abstract and concrete.
>>
>>
>> C and C++ are different accounts: they're also together an account.
>> Then, the resulting artifacts: has that C++ can link as it were
>> to the C symbols, and even the C can link as it were to name-mangled
>> C++, not that anybody ever does that since it involves the model in
>> the run-time their interpretation, point being libraries to be
>> interoperable with both C and C++ have C exports, then that it's
>> to be expected that C++ for example can deal with the allocator
>> or I/O stream, wrapping it into the C++ from a C way that must be
>> contrived.
> Maybe you should write a book. It would simultaneously be useful as a
> door-stop, and a cure for insomnia.
>

That's hilarious. I already have several 1,000's convenient door-stops,
though it's called "a library", and I read them, too.  Don't make me laugh.

I have a habit of neither snipping nor top-posting nor inserting,
since it might be considered rude. Also it's so that then I can
just extract the passages from some 10,000's essays of a sort,
since it's a linear narrative itself.

"Essays", are as since, for example, Montaigne: whose "Essais",
became the model for discursive writing, in the 1400's, for example
about essays and the di-alectic.


The other day there was a news article, something like "Von Plato
used A.I. to finally parse Goedel's manuscript notes and found a
bunch of un-known proofs", where something like Euler's or Leibniz'
volumes are on the order of 40,000 pages apiece, outside their
usual "canon" of well-known works on mathematics, about things
like Leibniz-studies.


How about this: how do you like to write C, in a world of C and C++?


Thanks for writing.




Technical Details
Message-ID: <BOmdncI_EeozMmD3nZ2dnZfqnPudnZ2d@giganews.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
References: <yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com> <11d56gl$3ud5q$1@dont-email.me> <11d6vjp$qhu8$1@raubtier-asyl.eternal-september.org> <dsednTD-Fblclmr3nZ2dnZfqnPWdnZ2d@giganews.com> <11d738r$ru7a$1@dont-email.me> <11d75i7$spj0$1@dont-email.me> <11d7c8k$173nk$1@dont-email.me> <11d7fbv$1839o$2@dont-email.me> <PKGcne0xA53EC2D3nZ2dnZfqn_udnZ2d@giganews.com> <11dk8ib$1c198$1@dont-email.me>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Wed, 18 Nov 2026 14:01:18 +0000
Subject: Re: Inversion-of-control and dependency-injection in C
Newsgroups: comp.lang.c
References: <yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com>
 <11d56gl$3ud5q$1@dont-email.me>
 <11d6vjp$qhu8$1@raubtier-asyl.eternal-september.org>
 <dsednTD-Fblclmr3nZ2dnZfqnPWdnZ2d@giganews.com>
 <11d738r$ru7a$1@dont-email.me> <11d75i7$spj0$1@dont-email.me>
 <11d7c8k$173nk$1@dont-email.me> <11d7fbv$1839o$2@dont-email.me>
 <PKGcne0xA53EC2D3nZ2dnZfqn_udnZ2d@giganews.com>
 <11dk8ib$1c198$1@dont-email.me>
From: Ross Finlayson <ross.a.finlayson@gmail.com>
Date: Wed, 18 Nov 2026 06:01:26 -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: <11dk8ib$1c198$1@dont-email.me>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <BOmdncI_EeozMmD3nZ2dnZfqnPudnZ2d@giganews.com>
Lines: 149
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-N13D9IskiqeYqurtUpH4Mq67XwqHEloMBKJv+GDkeAYiRy2D1DlJzdLl5kQgLy7As+s2vG76IMz1Qsv!LmuEhITnRn8kG/G6Y71GoeN4JdXHjGsypaL6VzvvwkV3jNEdfbIuojIBMdVvSbrfK3TRLWBLyPFV
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