• Inversion-of-control and dependency-injection in C

    From Ross Finlayson@3:633/10 to All on Thu Nov 12 09:41:04 2026
    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    A usual account for example might recount component frameworks,
    like COM or XPCOM for example, about the concepts of components,
    vis-a-vis, modularity and composability, and, satisfaction of
    dependencies, vis-a-vis IPC and RPC, abstraction layers often enough,
    then about adapters to dependencies, or as for resources, that
    it's a bunch of makefiles with various accounts of conditional includes
    and build targets about static and dynamic linking and the toolchain,
    with regards to test-harness and runtime-framework and about
    metaprogramming when making code generation and boilerplate and so on.


    Defining an interface or layer is often enough about groups of functions associated with context-structs to make for lifecycles
    of what result alike the pure virtual or abstract or interfaces
    in reference to languages like C++, about families of functions
    according to the types of their signatures, then as with regards
    to componentry rather generally in value-types and interface-types
    like "variant" and "queryInterface()", about components that implement
    multiple interfaces vis-a-vis mostly about "constructing the
    object-graph" what makes for separation-of-concerns and composability,
    is mostly about modularity and composability.

    Then considerations of modularity as for library design affect to
    reflect on how to indicate responsibilities of ownership in resources,
    for example to hide contract & behavior of resources acquire/release.

    What I'm figuring is that basically there is a flat name-space of
    functions, there are .h and .c files (and may include "portable
    assembler"), and there is the compiler-toolchain, and make or
    build-scripts. Since there are only functions then dependencies their references would basically live in structs (in structs, in structs, ...,
    of function pointers), much like languages with classes and their
    instances objects and subclassing overriding behavior keeping in
    contract, about how to define "runtime-module" vis-a-vis "source module"
    (.o files after compilation-units), about conditional-includes
    and conditional-builds vis-a-vis name-mangling or the conventions of
    symbols.

    What, whither, when, how?


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 12 20:25:40 2026
    Ross Finlayson pisze:
    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    A usual account for example might recount component frameworks,
    like COM or XPCOM for example, about the concepts of components,
    vis-a-vis, modularity and composability, and, satisfaction of
    dependencies, vis-a-vis IPC and RPC, abstraction layers often enough,
    then about adapters to dependencies, or as for resources, that
    it's a bunch of makefiles with various accounts of conditional includes
    and build targets about static and dynamic linking and the toolchain,
    with regards to test-harness and runtime-framework and about
    metaprogramming when making code generation and boilerplate and so on.


    Defining an interface or layer is often enough about groups of functions associated with context-structs to make for lifecycles
    of what result alike the pure virtual or abstract or interfaces
    in reference to languages like C++, about families of functions
    according to the types of their signatures, then as with regards
    to componentry rather generally in value-types and interface-types
    like "variant" and "queryInterface()", about components that implement multiple interfaces vis-a-vis mostly about "constructing the
    object-graph" what makes for separation-of-concerns and composability,
    is mostly about modularity and composability.

    Then considerations of modularity as for library design affect to
    reflect on how to indicate responsibilities of ownership in resources,
    for example to hide contract & behavior of resources acquire/release.

    What I'm figuring is that basically there is a flat name-space of
    functions, there are .h and .c files (and may include "portable
    assembler"), and there is the compiler-toolchain, and make or
    build-scripts. Since there are only functions then dependencies their references would basically live in structs (in structs, in structs, ...,
    of function pointers), much like languages with classes and their
    instances objects and subclassing overriding behavior keeping in
    contract, about how to define "runtime-module" vis-a-vis "source module"
    (.o files after compilation-units), about conditional-includes
    and conditional-builds vis-a-vis name-mangling or the conventions of
    symbols.

    What, whither, when, how?


    this is not a large group and stating such soecific and wide question
    you minimalise the chance of answers to it to nearly zero

    you can enentually "answer to yourself" (as some say i do? well if i
    state question and some cant answer it after some time i myself may
    answer it) - though im usually not answering my own questions
    (sometimes) but simply "adding" more thoughts to prewious ones
    (which is qute good coz articles splitted on more parts ere better)



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Nov 12 20:38:19 2026
    Am 12.11.2026 um 18:41 schrieb Ross Finlayson:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.
    Works magnitudes better in C++ with std::function<> and generic
    function objects. F.e. when using std::find_if, std::sort etc.
    C sucks.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 12 20:39:21 2026
    fir pisze:
    Ross Finlayson pisze:
    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    A usual account for example might recount component frameworks,
    like COM or XPCOM for example, about the concepts of components,
    vis-a-vis, modularity and composability, and, satisfaction of
    dependencies, vis-a-vis IPC and RPC, abstraction layers often enough,
    then about adapters to dependencies, or as for resources, that
    it's a bunch of makefiles with various accounts of conditional includes
    and build targets about static and dynamic linking and the toolchain,
    with regards to test-harness and runtime-framework and about
    metaprogramming when making code generation and boilerplate and so on.


    Defining an interface or layer is often enough about groups of functions
    associated with context-structs to make for lifecycles
    of what result alike the pure virtual or abstract or interfaces
    in reference to languages like C++, about families of functions
    according to the types of their signatures, then as with regards
    to componentry rather generally in value-types and interface-types
    like "variant" and "queryInterface()", about components that implement
    multiple interfaces vis-a-vis mostly about "constructing the
    object-graph" what makes for separation-of-concerns and composability,
    is mostly about modularity and composability.

    Then considerations of modularity as for library design affect to
    reflect on how to indicate responsibilities of ownership in resources,
    for example to hide contract & behavior of resources acquire/release.

    What I'm figuring is that basically there is a flat name-space of
    functions, there are .h and .c files (and may include "portable
    assembler"), and there is the compiler-toolchain, and make or
    build-scripts. Since there are only functions then dependencies their
    references would basically live in structs (in structs, in structs, ...,
    of function pointers), much like languages with classes and their
    instances objects and subclassing overriding behavior keeping in
    contract, about how to define "runtime-module" vis-a-vis "source module"
    (.o files after compilation-units), about conditional-includes
    and conditional-builds vis-a-vis name-mangling or the conventions of
    symbols.

    What, whither, when, how?


    this is not a large group and stating such soecific and wide question
    you minimalise the chance of answers to it to nearly zero

    you can enentually "answer to yourself" (as some say i do? well if i
    state question and some cant answer it after some time i myself may
    answer it) - though im usually not answering my own questions
    (sometimes) but simply "adding" more thoughts to prewious ones
    (which is qute good coz articles splitted on more parts ere better)


    overally people seem to ba rather weak in answering some more 'meta'
    questions (which is not strightforward as in the net (articles etc) i sometimes see lile people would be interested in meta topic to,
    but on c.l.c meta questions are rarely answered)

    if they will do i mayself would ask:

    have you noticed that mess rises in your code/projects ?
    what you do with that

    for exampel in my rasterizer/3d shooter prototype i read
    keys - it comes from wndproc key handler but as code grows larger
    damn i got not in memory where given key ich checked
    (as its handy and logical to check it close to its functionality,
    sometimes it is in general window handling, sometimes its in
    hud block, sometimes its in the scene root area sometimes its
    in the loop of objests

    good luck to finding it

    and that is how mess grows

    (its maybe not even mess - its maybe things dont fit in my memory
    so i must load it, and damn its slow

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 12 20:55:24 2026
    fir pisze:
    fir pisze:
    Ross Finlayson pisze:
    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control >>> and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    A usual account for example might recount component frameworks,
    like COM or XPCOM for example, about the concepts of components,
    vis-a-vis, modularity and composability, and, satisfaction of
    dependencies, vis-a-vis IPC and RPC, abstraction layers often enough,
    then about adapters to dependencies, or as for resources, that
    it's a bunch of makefiles with various accounts of conditional includes
    and build targets about static and dynamic linking and the toolchain,
    with regards to test-harness and runtime-framework and about
    metaprogramming when making code generation and boilerplate and so on.


    Defining an interface or layer is often enough about groups of functions >>> associated with context-structs to make for lifecycles
    of what result alike the pure virtual or abstract or interfaces
    in reference to languages like C++, about families of functions
    according to the types of their signatures, then as with regards
    to componentry rather generally in value-types and interface-types
    like "variant" and "queryInterface()", about components that implement
    multiple interfaces vis-a-vis mostly about "constructing the
    object-graph" what makes for separation-of-concerns and composability,
    is mostly about modularity and composability.

    Then considerations of modularity as for library design affect to
    reflect on how to indicate responsibilities of ownership in resources,
    for example to hide contract & behavior of resources acquire/release.

    What I'm figuring is that basically there is a flat name-space of
    functions, there are .h and .c files (and may include "portable
    assembler"), and there is the compiler-toolchain, and make or
    build-scripts. Since there are only functions then dependencies their
    references would basically live in structs (in structs, in structs, ..., >>> of function pointers), much like languages with classes and their
    instances objects and subclassing overriding behavior keeping in
    contract, about how to define "runtime-module" vis-a-vis "source module" >>> (.o files after compilation-units), about conditional-includes
    and conditional-builds vis-a-vis name-mangling or the conventions of
    symbols.

    What, whither, when, how?


    this is not a large group and stating such soecific and wide question
    you minimalise the chance of answers to it to nearly zero

    you can enentually "answer to yourself" (as some say i do? well if i
    state question and some cant answer it after some time i myself may
    answer it) - though im usually not answering my own questions
    (sometimes) but simply "adding" more thoughts to prewious ones
    (which is qute good coz articles splitted on more parts ere better)


    overally people seem to ba rather weak in answering some more 'meta' questions (which is not strightforward as in the net (articles etc) i sometimes see lile people would be interested in meta topic to,
    but on c.l.c meta questions are rarely answered)

    if they will do i mayself would ask:

    have you noticed that mess rises in your code/projects ?
    what you do with that

    for exampel in my rasterizer/3d shooter prototype i read
    keys - it comes from wndproc key handler but as code grows larger
    damn i got not in memory where given key ich checked
    (as its handy and logical to check it close to its functionality,
    sometimes it is in general window handling, sometimes its in
    hud block, sometimes its in the scene root area sometimes its
    in the loop of objests

    good luck to finding it

    and that is how mess grows

    (its maybe not even mess - its maybe things dont fit in my memory
    so i must load it, and damn its slow

    note i once emphasized what i call "code jumping"

    the fact that in larger projest and with some specific codes
    to write something you must travel thru code (mostly up and down or
    jum to anothe files ) now i could extend it to this mehanism of
    "memory loading" (not only you need to jump but you must memorize where
    is what) (yawn..and thsi damn slowing)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lew Pitcher@3:633/10 to All on Thu Nov 12 20:11:01 2026
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?

    --
    Lew Pitcher
    "In Skills We Trust"
    Not LLM output - I'm just like this.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Thu Nov 12 12:15:45 2026
    On 11/12/2026 11:38 AM, Bonita Montero wrote:
    Am 12.11.2026 um 18:41 schrieb Ross Finlayson:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.
    Works magnitudes better in C++ with std::function<> and generic
    function objects. F.e. when using std::find_if, std::sort etc.
    C sucks.


    C is C. Imvvvvho, C++ is better... :^) Let the flames begin.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Richard Harnden@3:633/10 to All on Thu Nov 12 20:55:40 2026
    On 12/11/2026 20:11, Lew Pitcher wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?


    Or get an AI do to your homework?

    Be careful to remove the white-on-white-very-small-font gotcha your
    professor doubtlessly put in.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Thu Nov 12 13:15:25 2026
    On 11/12/2026 12:11 PM, Lew Pitcher wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?


    Not at all, meaning, no offense taken.

    How about "writing testable code", what are common frameworks
    or best practices for "writing testable code" in C.

    I'd suggest abstraction and layers and modularity and composability,
    and having an inversion-of-control/dependency-injection approach,
    a convention moreso than a framework, which pretty much means wrapping
    all the standard functions, then about for example having an include
    where those are wrapper functions to stub and mock, and another include
    where those are macros, or, perhaps, using includes, to point the
    include directory for the standard library, into instead what makes
    for stubbable/mockable calls to standard library and system functions,
    or just leaving the headers alone and linking to modules that aren't
    the standard libraries, this being an example of something like
    "can't mock strftime", or, for an example.

    Then, about the modularity, and pointers (to pointers to pointers
    to pointers, ...) to functions, then seems about conventions of
    types for typeof and the like about that like anybody else I rely
    on the compiler to fail with -Wall and failing on warnings to
    catch type errors, ..., has that I want to program to interfaces
    and then have objects composable, ..., about using conditions of
    the build, to, basically make for test-time targets and run-time
    targets, with actually testing the code that goes into the build.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Thu Nov 12 13:44:15 2026
    On 11/12/2026 12:55 PM, Richard Harnden wrote:
    On 12/11/2026 20:11, Lew Pitcher wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control >>> and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?


    Or get an AI do to your homework?

    Be careful to remove the white-on-white-very-small-font gotcha your
    professor doubtlessly put in.




    When I use "A.I." it's framed as a dialogue and I just copy the
    transcripts directly, with the attributions.

    I.e., I've never submitted anything to Usenet written by a bot
    on my behalf.


    I'm not sure whether I'd call it "distance learning", or,
    "distance learning", say, ....




    Like say for example I'm looking at something like this that I tapped
    up this morning, and I want to figure out then how to make it so that
    the guts of the workers have a nice real quality of covering all the
    bases of covering all the cases, when for example according to the C
    host as it were or POSIX there's signals and traps to be figured out
    in accounts of "asynchronous concurrency".






    Outline of "I/O-handle-bound process model"

    The "I/O-handle-bound process model", is an account of a process group
    in a process tree,
    that works up to the bounds of 1024 many file-descriptors that a
    pselect() call can poll,
    with up to 1000-many file-descriptors in up to 1000-many worker
    processes, for up to
    1,000,000-many open connections.

    The "1000-many" is basically derived from FD_SETSIZE having a limit of
    1024,
    and that numbered file-descriptors that can participate in non-blocking I/O with pselect() notification of readiness, must be less than FD_SETSIZE
    their value.

    The basic idea is that there's a main or master process, that being also
    the process group leader,
    that has a "process-protocol" convention, that the master/leader, has
    domain sockets
    to its child processes, with up to 1000-many worker processes, then
    other processes
    as the listener, which accepts connections, and a logger and a metrics
    process.

    The listener is its own process that does accept and management (figured
    IP address listing and perhaps a tiny bit of TLS business). It's figured
    that it's
    an Internet protocol server, and "connection-oriented", or as mostly
    about TCP/IP,
    and furthermore "association-oriented", about SCTP, then about UDP or
    datagram
    "protocols", the listener demultiplexes the packets as "connections" to
    the workers.

    The file-descriptors in a process are numbered, non-negative integers.

    The file-descriptors 0, 1, 2 are ubiqitously stdin, stdout, stderr,
    "standard input-output-error".

    The file-descriptor 3 is reserved as it may be a convention for passing
    open connections to created processes.

    The file-descriptors 4, 5, 6 are reserved as "stdlog, stdmet, stddmp", "logging-metrics-dump outputs".

    The file-descriptors 21-1020 are reserved for "1000-many connections".

    The leader uses the "1000-many connections" for domain sockets to its "1000-many workers".

    Each follower (listener, worker, ...) has a reserved file-descriptor
    (11) to connect with the leader.

    The leader uses file-descriptor 11 to connect to the listener.
    The leader uses file-descriptor 12 to connect to an optional console.
    The leader uses file-descriptor 13 to connect to an optional logger.
    The leader uses file-descriptor 14 to connect to an optional metrics.

    launcher

    leader

    logger
    metrics
    console

    listener
    worker

    The model of operation describes how a process is created, according to
    fork and execve.

    The file-descriptors 0-10 are "standard", about stdin/stdout/stderr and
    these
    named stdlog/stdmet/stddmp. Usually stdin is un-read, or set to /dev/null. Usually stdout and stderr are inherited (by all child processes) from
    leader.

    The stdlog and stdmet and stddmp are inherited from leader. A usual idea is that these as file-handles may be passed to the leader for example to
    the shell,
    or that usually according to options, the first child processes of the
    leader are
    the logger and metrics, with the logger and metrics receiving all the
    messages
    on those handles, then the leader and all other processes sharing those handles,
    and all writing the logs and metrics to those same handles. Then, the
    dumper
    is an abstract output stream, outside of logging and metrics and
    standard I/O.

    The file-descriptors 11-20 are in the "process-protocol".

    The file-descriptors 21-1020 of the leader are in the "process-protocol".
    The file-descriptors 21-1020 of the listener are in the "process-protocol".
    The file-descriptors 21-1020 of the workers are in the
    "application-protocol".

    The file-descriptor 3 in the listener is the listening socket.
    The file-descriptor 3 may be passed to the leader to be passed to the
    listener,
    the listening socket.

    leader:
    4 -> stdlog
    5 -> stdmet
    6 -> stddmp
    11 <-> logger
    12 <-> metrics
    13 <-> listener
    14 <-> console
    21-1020 <-> workers

    logger:
    4 <- stdlog
    6 <- stddmp
    11 <-> logger (leader)
    12 <-> metrics

    metrics:
    5 <- stdmet
    11 <-> logger
    12 <-> metrics (leader)


    listener:
    4 -> stdlog
    5 -> stdmet
    6 -> stddmp
    11 <-> logger
    12 <-> metrics
    13 <-> listener (leader)
    14-20 <-> listening socket(s)
    21-1020 <-> workers

    worker:
    4 -> stdlog
    5 -> stdmet
    6 -> stddmp
    11 <-> leader
    13 <-> listener
    21-1020 -> connections (front-end and back-end)

    Each of these has their own "main()" source code and executable,
    with that each is created by leader with fork() then setting the handles respectively, then execve() thus that the child processes start with
    their open handles in the process-protocol (11-20) and stdio (0-10)
    already opened and directed.

    Then, the process-protocol is according to use-cases, as driven by
    events, about that the domain-sockets that are under the handles
    of the process-protocol, make for passing data, and also live handles,
    as are the connections.


    The main use-case is that the listener is bound to a listening socket,
    as connections are accepted with connection-management happening
    in the listener, listener passes the connection to leader, which finds or create a worker, and passes the connection to worker, which then
    proceeds to service the connection according to the application-protocol.

    listener: accepts connection

    listener -> leader: connection-accepted !
    leader -> worker: connection-ready ?
    worker -> leader: connection-ready !
    leader -> listener: pass-ready !
    listener -> leader: connection-pass !
    leader -> worker: connection-pass !

    When a connection is closed, according to the application-protocol
    or if the connection drops or is severed, then worker advises leader,
    then leader advises listener.

    worker -> leader: connection-closed
    leader -> listener: connection-closed

    Then, when there are process-level events, the leader makes
    commands to the workers, about graceful exit.

    leader -> worker: drain connections
    leader -> worker: close connections
    leader -> worker: exit

    Since connections and their attachments & associations
    may be short-lived or long-lived, and the goal is that
    there only needs be as many workers as fulfill servicing
    the connections, then is that there's a process-protocol
    about migrating associations (and their connections)
    among workers, usually from "sparse" workers to "dense"
    workers, where sparse means "not-very-full" and dense
    means "not-very-empty", or from "short-lived" workers
    to "long-lived" workers when connections are long-lived,
    that "association migration" is in the process-protocol.

    leader -> worker: emigrate-association
    worker -> leader: migrate-association
    leader -> worker: immigrate-association


    The threading model in the process model

    The basic idea of the threading model is that workers
    are multi-threaded, the leader is single-threaded, and
    that the threads "park" when there is no activity,
    yet that the workers have one "sweeper" thread
    to account for time-outs, then that as the workers
    close their connections, they exit, so that under no
    traffic, there is no activity, with all processes "parked".

    The idea of "parking" is blocking on the inputs to the
    protocols, or the event-driven pumps in the workers.

    The threads basically block in pselect() waiting for
    ready reading, writing, or other events, or, waiting
    on a queue item, pop().

    The leader parks in pselect() on 11-1024, the process-protocol.

    The listener parks in pselect() about
    accept() and pselect() on the listening socket and
    the process-protocol sockets.

    The worker has four or more threads.

    reader-thread: parks in pselect() with read-interest
    executor-thread: parks in pop() of application-protocol tasks
    writer-thread: parks in pop() of application-protocol responses, then
    blocks in pselect() while writing, then parks
    sweeper-thread: according to time/alarm, runs on a frequency eg 500 milliseconds, 5 seconds, 5 minutes

    When the worker is empty, after its connections close, it exits.

    The logger and metrics park in pselect() on the read-side of stdlog/stdmet/stddmp.

    Thusly, at idle, with no connections, the entire process-group is
    "parked" (0% CPU, "acquiescent").








    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Fri Nov 13 00:26:16 2026
    On 2026-11-12 22:15, Ross Finlayson wrote:
    On 11/12/2026 12:11 PM, Lew Pitcher wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control >>> and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?

    Not at all, meaning, no offense taken.

    Your original post and its intention had been also to me quite
    unclear. Here, now, I seem to understand at what you are aiming.

    (Disclaimer: my comments are just based on personal experience
    in our software developing practice from the 1990's and not some
    general accepted opinion or habits.)

    How about "writing testable code", what are common frameworks
    or best practices for "writing testable code" in C.

    Our approach was not to "write testable code" by _adapting_ to
    some existing framework. While we had standards and practices how
    to design software the _tests followed our software_ (not v.v.).
    One exception here was that including dedicated trace records in
    our code (that could be activated specifically WRT a module and
    in granularity) helped for the test evaluation and regressions.

    Then we have to differentiate what tests you have in mind here;
    there's various types of tests which require their own principles.
    For example; Unit Tests (in our [C++] context mainly classes, in
    "C" probably functions or a set of related functions) required
    functions that own little test programs would call to verify all
    the relevant conditions. We haven't used frameworks that created
    the tests but wrote our own dedicated test-functions along with the
    application functions. For our Component Tests (where components
    were in our case software pieces that constitute runtime processes
    with a well-defined interface) we wrote stubs that could challenge
    the components on the interface levels. Such stubs could operate
    some predefined procedures with well-defined input, or arbitrary
    data, or be an operator-triggered manual interaction, depending on
    the type of the component. Storing all the test input and output
    results made regression tests possible. For the Integration Tests I
    don't recall the procedures (it was done in a dedicated integration
    test group); but they defined and checked the system configuration,
    the interoperability (I think!) mostly manually. Malfunctions were
    reported back to development accompanied by protocols, traces, and
    actual data. The System Tests were checked against the specification
    documents, and the Acceptance Tests against the requirements specs,
    sometimes accompanied by the customers. One aspect yet not listed
    was the test of the GUIs; beside manual tests we used tools to do
    all that "mouse shoving and clicking". But given that the functional
    tests already happened on the automatable interface level in former
    stages that was effectively just to check the "UI ergonomy" ("UX")
    factors. And, finally, we had our own hierarchical regression test
    framework to run and document the tests on each abstraction stage.
    (Eventually there were also external third-party tools existing but
    back then we wrote (had to write) our own regression test framework
    that fulfilled our demands.)


    I'd suggest abstraction and layers and modularity and composability,

    Yes, those are principles that support the mentioned QA processes.

    and having an inversion-of-control/dependency-injection approach,

    (See my comment about "tests follow code (not v.v.)". - Opinions may
    differ.)

    a convention moreso than a framework, which pretty much means wrapping
    all the standard functions, then about for example having an include
    where those are wrapper functions to stub and mock, and another include
    where those are macros, or, perhaps, using includes, to point the
    include directory for the standard library, into instead what makes
    for stubbable/mockable calls to standard library and system functions,
    or just leaving the headers alone and linking to modules that aren't
    the standard libraries, this being an example of something like
    "can't mock strftime", or, for an example.

    Just a comment on one aspect here; yes, you have to organize your
    software and tests. Key principles are the modularity, hierarchical organization, being able to automate processes, and organize all in
    some consistent way. In case your company is certified (or wants to
    get certified) make sure your processes are documented and that you
    can reproduce your quality processes and the results.


    Then, about the modularity, and pointers (to pointers to pointers
    to pointers, ...) to functions, then seems about conventions of
    types for typeof and the like about that like anybody else I rely
    on the compiler to fail with -Wall and failing on warnings to
    catch type errors, ..., has that I want to program to interfaces
    and then have objects composable, ..., about using conditions of
    the build, to, basically make for test-time targets and run-time
    targets, with actually testing the code that goes into the build.

    It's not clear to me what you want to say here but it sounds that
    you want very specific ("micro-management") advice on a low level?
    (If so, I can't and don't want to comment here.)

    (All above from memories and off the top of my head. Hope there's
    something useful for your purpose.)

    Janis


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Thu Nov 12 17:22:00 2026
    On 11/12/2026 03:26 PM, Janis Papanagnou wrote:
    On 2026-11-12 22:15, Ross Finlayson wrote:
    On 11/12/2026 12:11 PM, Lew Pitcher wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of
    inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes >>>> and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?

    Not at all, meaning, no offense taken.

    Your original post and its intention had been also to me quite
    unclear. Here, now, I seem to understand at what you are aiming.

    (Disclaimer: my comments are just based on personal experience
    in our software developing practice from the 1990's and not some
    general accepted opinion or habits.)

    How about "writing testable code", what are common frameworks
    or best practices for "writing testable code" in C.

    Our approach was not to "write testable code" by _adapting_ to
    some existing framework. While we had standards and practices how
    to design software the _tests followed our software_ (not v.v.).
    One exception here was that including dedicated trace records in
    our code (that could be activated specifically WRT a module and
    in granularity) helped for the test evaluation and regressions.

    Then we have to differentiate what tests you have in mind here;
    there's various types of tests which require their own principles.
    For example; Unit Tests (in our [C++] context mainly classes, in
    "C" probably functions or a set of related functions) required
    functions that own little test programs would call to verify all
    the relevant conditions. We haven't used frameworks that created
    the tests but wrote our own dedicated test-functions along with the application functions. For our Component Tests (where components
    were in our case software pieces that constitute runtime processes
    with a well-defined interface) we wrote stubs that could challenge
    the components on the interface levels. Such stubs could operate
    some predefined procedures with well-defined input, or arbitrary
    data, or be an operator-triggered manual interaction, depending on
    the type of the component. Storing all the test input and output
    results made regression tests possible. For the Integration Tests I
    don't recall the procedures (it was done in a dedicated integration
    test group); but they defined and checked the system configuration,
    the interoperability (I think!) mostly manually. Malfunctions were
    reported back to development accompanied by protocols, traces, and
    actual data. The System Tests were checked against the specification documents, and the Acceptance Tests against the requirements specs,
    sometimes accompanied by the customers. One aspect yet not listed
    was the test of the GUIs; beside manual tests we used tools to do
    all that "mouse shoving and clicking". But given that the functional
    tests already happened on the automatable interface level in former
    stages that was effectively just to check the "UI ergonomy" ("UX")
    factors. And, finally, we had our own hierarchical regression test
    framework to run and document the tests on each abstraction stage. (Eventually there were also external third-party tools existing but
    back then we wrote (had to write) our own regression test framework
    that fulfilled our demands.)


    I'd suggest abstraction and layers and modularity and composability,

    Yes, those are principles that support the mentioned QA processes.

    and having an inversion-of-control/dependency-injection approach,

    (See my comment about "tests follow code (not v.v.)". - Opinions may
    differ.)

    a convention moreso than a framework, which pretty much means wrapping
    all the standard functions, then about for example having an include
    where those are wrapper functions to stub and mock, and another include
    where those are macros, or, perhaps, using includes, to point the
    include directory for the standard library, into instead what makes
    for stubbable/mockable calls to standard library and system functions,
    or just leaving the headers alone and linking to modules that aren't
    the standard libraries, this being an example of something like
    "can't mock strftime", or, for an example.

    Just a comment on one aspect here; yes, you have to organize your
    software and tests. Key principles are the modularity, hierarchical organization, being able to automate processes, and organize all in
    some consistent way. In case your company is certified (or wants to
    get certified) make sure your processes are documented and that you
    can reproduce your quality processes and the results.


    Then, about the modularity, and pointers (to pointers to pointers
    to pointers, ...) to functions, then seems about conventions of
    types for typeof and the like about that like anybody else I rely
    on the compiler to fail with -Wall and failing on warnings to
    catch type errors, ..., has that I want to program to interfaces
    and then have objects composable, ..., about using conditions of
    the build, to, basically make for test-time targets and run-time
    targets, with actually testing the code that goes into the build.

    It's not clear to me what you want to say here but it sounds that
    you want very specific ("micro-management") advice on a low level?
    (If so, I can't and don't want to comment here.)

    (All above from memories and off the top of my head. Hope there's
    something useful for your purpose.)

    Janis


    Thanks for writing.

    Usually enough these days with alike "CI/CD", ..., or the latest
    buzzwords of 2018, there's "build & test & scan & deploy", usually
    enough that "build & test & scan" is usually enough for "the artifacts",
    the build artifacts and the test artifacts and so on.
    When "automating the pipeline" and these kinds of things, it's not
    un-usual that the test-suite whatever it may be, has that there are
    some XML formats that are readily ingested and fungible to the
    framework, vis-a-vis, usually enough it's that "./test returns
    either EXIT_SUCCESS or EXIT_FAILURE and that's our predicate
    and build-step and action and work-flow too in our Git Hub/Lab".

    So, for whatever results "test: pass/fail", may make for that
    there are fungible report formats that might be useful downstream,
    for example "automated code-reviews that show what broke where, when".


    So, agreeably, basically it's figured a build step.

    Then, it sounds like we're both familiar with settings where
    the notions of "unit tests, module tests, integration tests,
    end-to-end tests, smoke-tests, sanity-tests, activation-tests",
    representing ye olde "acceptance criteria" usually though often
    practically "broken" or "not broken" the build, then about the
    mania for "branch and line coverage, with whatever possible stubs
    and mocks make the instrumented code covered", that's agreeable
    and usual.


    Then, about testing the black-box or white-box, say, here it's
    considered that both are apropos, like for example "health checks
    and internal and external health checks". Then, here's a sort of
    example, if you're familiar with something like "React and Angular
    and these sorts of front-ends". So, often there are things like
    "jest tests then Web Driver and somebody walked through the work-flows
    and it re-plays them and it only takes 8 GiB and forty-five minutes".
    Well, that's with the expectation that "it has to run in the browser",
    yet, at one point it was reasonably simple, for example for "React",
    about 16 or 17 I suppose, to just implement "the algorithm" and just
    include a file that basically modeled the runtime, then it can test
    all the workflows programmatically, as a sort of example. That
    got less possible when "effects" were added, yet otherwise it
    was possible to have it "test" a lot faster.

    It's agreeable that it may be impossible to model the system in
    software when it's involved a system, and, black-box and integration
    tests ("don't forget regression!"), then it may also be so that
    a sort of mini-model of the surface of the library and framework
    that's used, can be much, much reduced, from all the library. For
    example, say "C" has 100's standard functions and "POSIX" hundreds
    more. Well, often I have here programs that effectively use dozens, or
    less. Then, the model of the machine is plenty involved, like "the
    operating system" and "the process model" and "handles" and "sockets"
    and "signals" all that, it may make sense though to make "mini-models", basically emulating "the surface", i.e., "the test-able surface".


    Then, about C, which may be less structured for abstraction as
    modeling the surface of the run-time, has that many use-cases
    only use a tiny, tiny fraction of the run-time, about figuring
    that as modular and composable, and with basically zero available
    tooling, this kind of thing.


    Abstraction introduces complexity, and indirection, with the
    usual idea that it compiles to what's the "zero-cost abstraction",
    i.e. the abstraction gets compiled away, here basically about
    replacing the implementations of the standard and library functions
    with a, "mini-model", of operation, then to sort of build that
    and make it re-usable, then to be able to build unit-tests off
    that (and, you know, unit tests of those, ..., peeling-the-onion),
    that "verified" and "certified" are like "validated" and only
    "not falsified" and "not in-verified" and "not in-certified"
    and "not in-validated", ..., then for "module tests" after those
    unit test, then after the real build artifacts built against the
    real dependencies, integration and so on.






    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Fri Nov 13 05:28:28 2026
    In article <11d56gl$3ud5q$1@dont-email.me>,
    Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?

    It is obvious AI (*) slop. Can we just ignore this and move on?

    (*) Oops. Sorry. I mean, "SI".

    Oh, and can you believe that the SI industry is all in a tizzy and could
    very well crash and wipe out trillions in paper wealth, just because of
    some guy having extramarital sex? I thought we left that sort of thing
    behind in the 90s (the last time we got all in a tizzy about this sort of
    thing being Bill Clinton...)

    --
    "You can safely assume that you have created God in your own image when
    it turns out that God hates all the same people you do." -- Anne Lamott


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Paul@3:633/10 to All on Fri Nov 13 04:09:55 2026
    On Fri, 11/13/2026 12:28 AM, Kenny McCormack wrote:
    In article <11d56gl$3ud5q$1@dont-email.me>,
    Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control >>> and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?

    It is obvious AI (*) slop. Can we just ignore this and move on?

    (*) Oops. Sorry. I mean, "SI".

    Oh, and can you believe that the SI industry is all in a tizzy and could
    very well crash and wipe out trillions in paper wealth, just because of
    some guy having extramarital sex? I thought we left that sort of thing behind in the 90s (the last time we got all in a tizzy about this sort of thing being Bill Clinton...)


    I think the issue is violation of export law.

    You can see how they handle "pure diddling", in the first incident
    (swept under the rug). But this is different, because of the export law thing.

    If he hadn't helped the chick move 7.5 billion worth of equipment,
    the metrics would be different.

    Paul

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Fri Nov 13 10:18:40 2026
    Ross Finlayson pisze:
    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes
    and various build-targets, probably mostly about function pointers.

    A usual account for example might recount component frameworks,
    like COM or XPCOM for example, about the concepts of components,
    vis-a-vis, modularity and composability, and, satisfaction of
    dependencies, vis-a-vis IPC and RPC, abstraction layers often enough,
    then about adapters to dependencies, or as for resources, that
    it's a bunch of makefiles with various accounts of conditional includes
    and build targets about static and dynamic linking and the toolchain,
    with regards to test-harness and runtime-framework and about
    metaprogramming when making code generation and boilerplate and so on.


    Defining an interface or layer is often enough about groups of functions associated with context-structs to make for lifecycles
    of what result alike the pure virtual or abstract or interfaces
    in reference to languages like C++, about families of functions
    according to the types of their signatures, then as with regards
    to componentry rather generally in value-types and interface-types
    like "variant" and "queryInterface()", about components that implement multiple interfaces vis-a-vis mostly about "constructing the
    object-graph" what makes for separation-of-concerns and composability,
    is mostly about modularity and composability.

    Then considerations of modularity as for library design affect to
    reflect on how to indicate responsibilities of ownership in resources,
    for example to hide contract & behavior of resources acquire/release.

    What I'm figuring is that basically there is a flat name-space of
    functions, there are .h and .c files (and may include "portable
    assembler"), and there is the compiler-toolchain, and make or
    build-scripts. Since there are only functions then dependencies their references would basically live in structs (in structs, in structs, ...,
    of function pointers), much like languages with classes and their
    instances objects and subclassing overriding behavior keeping in
    contract, about how to define "runtime-module" vis-a-vis "source module"
    (.o files after compilation-units), about conditional-includes
    and conditional-builds vis-a-vis name-mangling or the conventions of
    symbols.

    What, whither, when, how?


    overally yours pyramide of this soft youre talkin about is build from
    small blocks/pieces (i dont mean pieces of code but some design pices
    (like alos this you mentioned dependency injection, inversion of
    controll and more)

    if you want answers ask some specific things on those pieces..asking
    on whole pyramid may be stupid as this stack of youre is probably quite specyfic - i would guess you have so many bad design decision stacked
    its in some wayj hopeless ;c (thoug hopeless is obviously an exagerration)

    i dont stack the bulshit and even in my case probblems appear when
    program is getting bigger


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Fri Nov 13 13:25:29 2026
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me.
    Mabye that's the joke ! ;-)


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Fri Nov 13 05:07:52 2026
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me.
    Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the
    application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke functions with data and assert(expected == actual)", that for example of
    "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and
    the usual object files in the usual object formats on the usual
    runtimes.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Fri Nov 13 13:27:55 2026
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me.
    Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke functions with data and assert(expected == actual)", that for example of
    "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and
    the usual object files in the usual object formats on the usual
    runtimes.
    This is not homework. And it's not written in good faith, it is just gobbledygook.

    I'm surprised so many here can't see it.

    Here is an interesting challenge: take a list of all these buzzwords,
    and try to write a set of viable-looking but meaningless paragraphs as
    Mr RF has done.

    You don't need to use a program to do it (although it would be most
    impressive as a C exercise).

    You win when a human mistakes it for something profound and insightful.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Fri Nov 13 05:50:15 2026
    On 11/13/2026 05:27 AM, bartc wrote:
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me.
    Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the
    bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the
    application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing
    frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke
    functions with data and assert(expected == actual)", that for example of
    "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and
    the usual object files in the usual object formats on the usual
    runtimes.
    This is not homework. And it's not written in good faith, it is just gobbledygook.

    I'm surprised so many here can't see it.

    Here is an interesting challenge: take a list of all these buzzwords,
    and try to write a set of viable-looking but meaningless paragraphs as
    Mr RF has done.

    You don't need to use a program to do it (although it would be most impressive as a C exercise).

    You win when a human mistakes it for something profound and insightful.


    You challenge my good faith, then to hell with you.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Richard Harnden@3:633/10 to All on Fri Nov 13 13:49:45 2026
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me.
    Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke functions with data and assert(expected == actual)", that for example of
    "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and
    the usual object files in the usual object formats on the usual
    runtimes.




    The answer is 'yes'. Or maybe 'no'. I'm not sure.

    What was the question?


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Fri Nov 13 05:56:21 2026
    On 11/13/2026 05:50 AM, Ross Finlayson wrote:
    On 11/13/2026 05:27 AM, bartc wrote:
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me. >>>> Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the
    bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the
    application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing
    frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke >>> functions with data and assert(expected == actual)", that for example of >>> "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and >>> the usual object files in the usual object formats on the usual
    runtimes.
    This is not homework. And it's not written in good faith, it is just
    gobbledygook.

    I'm surprised so many here can't see it.

    Here is an interesting challenge: take a list of all these buzzwords,
    and try to write a set of viable-looking but meaningless paragraphs as
    Mr RF has done.

    You don't need to use a program to do it (although it would be most
    impressive as a C exercise).

    You win when a human mistakes it for something profound and insightful.


    You challenge my good faith, then to hell with you.




    Basically free humans should make a nice new clean-room take on
    open source with stable interfaces, before the would-be bot-ocracy
    re-writes it as a warren and maze of dark twisty passages all alike.

    It might be eaten by a grue, ....



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Fri Nov 13 15:07:02 2026
    On 13/11/2026 14:27, bartc wrote:

    This is not homework. And it's not written in good faith, it is just gobbledygook.

    I'm surprised so many here can't see it.

    Here is an interesting challenge: take a list of all these buzzwords,
    and try to write a set of viable-looking but meaningless paragraphs as
    Mr RF has done.

    You don't need to use a program to do it (although it would be most impressive as a C exercise).

    You win when a human mistakes it for something profound and insightful.


    I don't think there is any bad-faith or trolling in Ross' posts - he
    seems simply incapable of writing comprehensibly. It is gobbledygook,
    but I don't see it as intentional.

    It looks like he is trying to ask something about how people test their
    C code, but I can't figure out anything more than that.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Fri Nov 13 06:24:30 2026
    On 11/13/2026 05:49 AM, Richard Harnden wrote:
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me.
    Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the
    bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the
    application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing
    frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke
    functions with data and assert(expected == actual)", that for example of
    "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and
    the usual object files in the usual object formats on the usual
    runtimes.




    The answer is 'yes'. Or maybe 'no'. I'm not sure.

    What was the question?



    How to design and make conventions and opinions and idiom and discipline
    the inversion-of-control and dependency-injection
    for the modularity and composability, in C? How do?

    For example, "what is good style in C to be idiomatic and
    direct in C toward zero-cost-abstraction, while yet directly
    resulting clean modular composable object-orientation in
    higher-level languages to wrap and interoperate, with
    modular and composable, and re-usable, and reliable,
    components in C?"



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Fri Nov 13 06:29:08 2026
    On 11/13/2026 06:24 AM, Ross Finlayson wrote:
    On 11/13/2026 05:49 AM, Richard Harnden wrote:
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me. >>>> Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the
    bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the
    application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing
    frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke >>> functions with data and assert(expected == actual)", that for example of >>> "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and >>> the usual object files in the usual object formats on the usual
    runtimes.




    The answer is 'yes'. Or maybe 'no'. I'm not sure.

    What was the question?



    How to design and make conventions and opinions and idiom and discipline
    the inversion-of-control and dependency-injection
    for the modularity and composability, in C? How do?

    For example, "what is good style in C to be idiomatic and
    direct in C toward zero-cost-abstraction, while yet directly
    resulting clean modular composable object-orientation in
    higher-level languages to wrap and interoperate, with
    modular and composable, and re-usable, and reliable,
    components in C?"



    Object-oriented programming, data-oriented programming,
    aspect-oriented programming, table-oriented programming,
    pattern-oriented programming, ....

    Systems programming, ..., application programming, ...,
    core programming, distributed programming, ....

    Procedural, function, literate, intentional, ....

    Modules. (Blocks and Modules, Modules and Interfaces.)



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Fri Nov 13 16:01:24 2026
    On 13/11/2026 14:07, David Brown wrote:
    On 13/11/2026 14:27, bartc wrote:

    This is not homework. And it's not written in good faith, it is just
    gobbledygook.

    I'm surprised so many here can't see it.

    Here is an interesting challenge: take a list of all these buzzwords,
    and try to write a set of viable-looking but meaningless paragraphs as
    Mr RF has done.

    You don't need to use a program to do it (although it would be most
    impressive as a C exercise).

    You win when a human mistakes it for something profound and insightful.


    I don't think there is any bad-faith or trolling in Ross' posts - he
    seems simply incapable of writing comprehensibly.˙ It is gobbledygook,
    but I don't see it as intentional.

    It looks like he is trying to ask something about how people test their
    C code, but I can't figure out anything more than that.


    How about this which was recently posted:

    RH:
    What was the question?


    RF:
    How to design and make conventions and opinions and idiom and discipline
    the inversion-of-control and dependency-injection
    for the modularity and composability, in C? How do?

    For example, "what is good style in C to be idiomatic and
    direct in C toward zero-cost-abstraction, while yet directly
    resulting clean modular composable object-orientation in
    higher-level languages to wrap and interoperate, with
    modular and composable, and re-usable, and reliable,
    components in C?"

    It is just utterly meaningless. Still think this is written in good
    faith? RF is just having a laugh.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Fri Nov 13 17:10:43 2026
    Ross Finlayson pisze:
    On 11/13/2026 05:49 AM, Richard Harnden wrote:
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me. >>>> Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the
    bus.)


    So, say I'm writing a usual sort of server with an idea that
    basically it's about "protocols", mostly, so, living in a world
    of the 7-layer OSI model, which is a pretty great abstraction and
    all the Internet protocols basically live in that world of definition,
    while though sometimes the network/transport then the
    application/presentation layers gets switched and crossed,
    point being there are systems with various accounts of moving parts
    and then is for testing in isolation the parts moving and also
    the moving of the parts.


    Then, lots of languages make great use of "reflection", which is
    an account of determining from the constructs their structure,
    which one may aver that that's what parser & compilers do already,
    and so if a C programmer needs reflection then if they're a real
    programmer or a real coder then they'd just make their own account
    of reflection and model the world in a model of the world, and
    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned
    into the language instead of libraries, or made standard, that
    since "run-time-type-identification" for example since something
    quite useful like "the variant data-type", sort of an "any: typed",
    that "reflection" and "introspection" are how most of the unit-testing
    frameworks make for inference about types then for conventions of
    signatures to make it easy the "test-fixtures", or otherwise the
    accounts of modularity and inversion-of-control and
    dependency-injection, then about something like C that it's "just invoke >>> functions with data and assert(expected == actual)", that for example of >>> "the many main()'s" just exec'ing those from the test process
    whether the tests exit(0) or exit(1), or rather as they die when
    assert evaluates false, for example as with regards when running
    under a debugger naturally just stopping there live in the debugger.


    So, among the goals of writing frameworks or tools or tests or
    systems, is that it works nicely with all the tools, according
    to usually enough just the totally common standards of the toolchain and >>> the usual object files in the usual object formats on the usual
    runtimes.




    The answer is 'yes'. Or maybe 'no'. I'm not sure.

    What was the question?



    How to design and make conventions and opinions and idiom and discipline
    the inversion-of-control and dependency-injection
    for the modularity and composability, in C? How do?

    For example, "what is good style in C to be idiomatic and
    direct in C toward zero-cost-abstraction, while yet directly
    resulting clean modular composable object-orientation in
    higher-level languages to wrap and interoperate, with
    modular and composable, and re-usable, and reliable,
    components in C?"

    in c you use dlls

    its reusable, reliable, modular, as far as i know is to be wrapped in hl languages, its lean ad modulat and forunatly its not OOP shit, its also probably idiomatis its direct and its about zero cost

    objet orientation s trash - hovever you could do it by writing some
    things that return handles but imo if you use handles its probably bad
    design (i rarely used handles - though dont ask me how to ot use handles
    as i donr remember when i wrota a code it just usually dont need
    handles (or i use it minimal way, i mean if handle is assigned
    immedatelly to a global variable its less dangerous/confusing)




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Fri Nov 13 17:54:23 2026
    On 13/11/2026 17:01, bartc wrote:
    On 13/11/2026 14:07, David Brown wrote:
    On 13/11/2026 14:27, bartc wrote:

    This is not homework. And it's not written in good faith, it is just
    gobbledygook.

    I'm surprised so many here can't see it.

    Here is an interesting challenge: take a list of all these buzzwords,
    and try to write a set of viable-looking but meaningless paragraphs
    as Mr RF has done.

    You don't need to use a program to do it (although it would be most
    impressive as a C exercise).

    You win when a human mistakes it for something profound and insightful.


    I don't think there is any bad-faith or trolling in Ross' posts - he
    seems simply incapable of writing comprehensibly.˙ It is gobbledygook,
    but I don't see it as intentional.

    It looks like he is trying to ask something about how people test
    their C code, but I can't figure out anything more than that.


    How about this which was recently posted:

    RH:
    What was the question?


    RF:
    How to design and make conventions and opinions and idiom and discipline the inversion-of-control and dependency-injection
    for the modularity and composability, in C? How do?

    For example, "what is good style in C to be idiomatic and
    direct in C toward zero-cost-abstraction, while yet directly
    resulting clean modular composable object-orientation in
    higher-level languages to wrap and interoperate, with
    modular and composable, and re-usable, and reliable,
    components in C?"

    It is just utterly meaningless. Still think this is written in good
    faith? RF is just having a laugh.

    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.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Fri Nov 13 14:50:35 2026
    On 11/13/2026 08:54 AM, David Brown wrote:
    On 13/11/2026 17:01, bartc wrote:
    On 13/11/2026 14:07, David Brown wrote:
    On 13/11/2026 14:27, bartc wrote:

    This is not homework. And it's not written in good faith, it is just
    gobbledygook.

    I'm surprised so many here can't see it.

    Here is an interesting challenge: take a list of all these
    buzzwords, and try to write a set of viable-looking but meaningless
    paragraphs as Mr RF has done.

    You don't need to use a program to do it (although it would be most
    impressive as a C exercise).

    You win when a human mistakes it for something profound and insightful. >>>>

    I don't think there is any bad-faith or trolling in Ross' posts - he
    seems simply incapable of writing comprehensibly. It is
    gobbledygook, but I don't see it as intentional.

    It looks like he is trying to ask something about how people test
    their C code, but I can't figure out anything more than that.


    How about this which was recently posted:

    RH:
    What was the question?


    RF:
    How to design and make conventions and opinions and idiom and
    discipline
    the inversion-of-control and dependency-injection
    for the modularity and composability, in C? How do?

    For example, "what is good style in C to be idiomatic and
    direct in C toward zero-cost-abstraction, while yet directly
    resulting clean modular composable object-orientation in
    higher-level languages to wrap and interoperate, with
    modular and composable, and re-usable, and reliable,
    components in C?"

    It is just utterly meaningless. Still think this is written in good
    faith? RF is just having a laugh.

    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.



    Hm.

    Yes, I've tapped 10,000's posts to Usenet with my own fat fingers.
    This includes basically research and a survey into "the Foundations
    of Mathematics", including a rather strong attack, then also I've
    been looking into physics for a while.

    I've written 100's KLOC's enterprise code, and generated tons more,
    at various outlets of "big tech", among my dozens logins.

    Also there are several hundred hours on my "YouTube" channel. All me.



    So, here's one. Say you got a server process for sockets of the connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and
    receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Sat Nov 14 08:09:17 2026
    Subject: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    In article <11d7fbv$1839o$2@dont-email.me>,
    David Brown <david.brown@hesbynett.no> 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.

    One word: fir.

    And, BTW, "joke" isn't quite the right word. It is more of thinking you
    are on a mission from God.

    --
    A 70 year old man who watches 6 hours of TV a day, plays a lot of golf
    and seems to always be in Florida is a retiree, not a president.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Sat Nov 14 11:49:15 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    Kenny McCormack pisze:
    In article <11d7fbv$1839o$2@dont-email.me>,
    David Brown <david.brown@hesbynett.no> 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.

    One word: fir.

    And, BTW, "joke" isn't quite the right word. It is more of thinking you
    are on a mission from God.


    maybe stap talkin bulshit kenny.. this pure fact ypou dont understand
    what im saying it dont means im on a mission from god (Crom is only a
    helper)

    im just doing some science on c syntax space, thats all

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Sat Nov 14 12:14:31 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    On 14/11/2026 08:09, Kenny McCormack wrote:
    In article <11d7fbv$1839o$2@dont-email.me>,
    David Brown <david.brown@hesbynett.no> 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.

    One word: fir.

    How about Bill Cunningham?



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Sat Nov 14 13:19:31 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    In article <11d9jb7$1tt0p$1@dont-email.me>, bartc <bc@freeuk.com> wrote:
    On 14/11/2026 08:09, Kenny McCormack wrote:
    In article <11d7fbv$1839o$2@dont-email.me>,
    David Brown <david.brown@hesbynett.no> 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.

    One word: fir.

    How about Bill Cunningham?



    Not sure I catch the reference, but I do vaguely remember that name being someone who used to post here.

    The thing is, though, when you get right down to it, nobody really knows
    why anyone posts here. I think each person who does does so for personal reasons that are in general not fully comprehensible by anyone else.

    Take the classic question: Why does Kenny McCormack post here, when all he
    does is troll? Well, he does it because it is fun and it amuses him.

    But I often ask: Why does KT post here? Since he obviously knows
    everything there is to know about C, why bother posting here? It's not
    like he is ever going to learn anything (since he already knows
    everything). Now, he will say, it is because he wants to help people.
    Well, this motive is already suspect (usually people who say they want to
    help people have some other motive, sometimes in addition to a genuine
    desire to help, but sometimes as the only motive), and, secondly, given how much effort he puts into it, it is hard to believe that altruism is the
    only reason.

    And you could ask similar questions about just about everyone else who
    posts to Usenet (not just this group) ?

    And so it goes...

    --
    Shikata ga nai...

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Sat Nov 14 14:33:41 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    Kenny McCormack pisze:
    In article <11d9jb7$1tt0p$1@dont-email.me>, bartc <bc@freeuk.com> wrote:
    On 14/11/2026 08:09, Kenny McCormack wrote:
    In article <11d7fbv$1839o$2@dont-email.me>,
    David Brown <david.brown@hesbynett.no> 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.

    One word: fir.

    How about Bill Cunningham?



    Not sure I catch the reference, but I do vaguely remember that name being someone who used to post here.

    The thing is, though, when you get right down to it, nobody really knows
    why anyone posts here. I think each person who does does so for personal reasons that are in general not fully comprehensible by anyone else.

    Take the classic question: Why does Kenny McCormack post here, when all he does is troll? Well, he does it because it is fun and it amuses him.

    But I often ask: Why does KT post here? Since he obviously knows
    everything there is to know about C, why bother posting here? It's not
    like he is ever going to learn anything (since he already knows
    everything). Now, he will say, it is because he wants to help people.
    Well, this motive is already suspect (usually people who say they want to help people have some other motive, sometimes in addition to a genuine
    desire to help, but sometimes as the only motive), and, secondly, given how much effort he puts into it, it is hard to believe that altruism is the
    only reason.

    And you could ask similar questions about just about everyone else who
    posts to Usenet (not just this group) ?

    And so it goes...


    i post here to increase my knowledge and understanding the c and "behind
    c" and im quite succesfull in it i would say (also note my plan is to
    code and thus write here till the end of the year, maybe enlonged to
    middle of januarry so later i may vanish for few months

    interesting in last years i get real long breaks on coding but this
    autumn thenx to ai it gave me a doze of fun again)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Sat Nov 14 08:17:12 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    On 11/14/2026 05:19 AM, Kenny McCormack wrote:
    In article <11d9jb7$1tt0p$1@dont-email.me>, bartc <bc@freeuk.com> wrote:
    On 14/11/2026 08:09, Kenny McCormack wrote:
    In article <11d7fbv$1839o$2@dont-email.me>,
    David Brown <david.brown@hesbynett.no> 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.

    One word: fir.

    How about Bill Cunningham?



    Not sure I catch the reference, but I do vaguely remember that name being someone who used to post here.

    The thing is, though, when you get right down to it, nobody really knows
    why anyone posts here. I think each person who does does so for personal reasons that are in general not fully comprehensible by anyone else.

    Take the classic question: Why does Kenny McCormack post here, when all he does is troll? Well, he does it because it is fun and it amuses him.

    But I often ask: Why does KT post here? Since he obviously knows
    everything there is to know about C, why bother posting here? It's not
    like he is ever going to learn anything (since he already knows
    everything). Now, he will say, it is because he wants to help people.
    Well, this motive is already suspect (usually people who say they want to help people have some other motive, sometimes in addition to a genuine
    desire to help, but sometimes as the only motive), and, secondly, given how much effort he puts into it, it is hard to believe that altruism is the
    only reason.

    And you could ask similar questions about just about everyone else who
    posts to Usenet (not just this group) ?

    And so it goes...



    Usenet is like a rather large bulletin-board system of the world,
    though I guess that's what "FIDO Net" is, federated bulletin-boards.
    Usenet has all the trappings the Internet, which it predates, i.e.
    pre-dates not pred-ates, where "predation" and "predating" are two
    different words, though, both I suppose gerunds, point being that Usenet
    has been around since before the Internet, and it has URL's and
    since every message ever posted is designed to have a unique ID,
    then also there are bibiographic citation standards about it,
    which might not mean much except that all the messages are distributed
    in the widely decentralized and available to any, in the public
    availability and not the public domain, as naturally authors maintain
    copyright of their postings they publish.


    Why people post to Usenet is for whatever reason they want
    and when they do is their own business, though it's rather
    explicitly not-for-commercial-purposes and it's not much
    for me to say how anti-spam works.

    Whether all gerunds end in "-ing" for example, there's a corner
    where once-upon-a-time people with strong opinions would weigh
    the question and merit the weights and politely and eruditely
    argue its alternatives, with great decorum and fine collegiality.

    ... Or flame all day, it's a free country.

    There are moderated groups, most dusty or defunct.


    Then, there are issues about that since the basically return-path
    is email, and email may be fakemail, and not all vectors into Usenet
    care, whether "Kenny McCormack", for example, inspired or mocks
    the character from "Spice Pork", who-made-who, has that it is or isn't
    so, then also that long before "A.I." was shored-up and silo'ed
    behind the more commercial accounts of "social media", there are
    tons bots among the trolls, usually with stolen identities from
    dupes on the Internet who'd never notice, yet of course that sort
    of practice is way more evident in the modern commercial accounts
    of "social media" with the "I.A.: instant audience" of simple
    bot-fan and bot-troll accounts of click-fraud and propagandist spew.


    Then, a key account of the Usenet is the co-operative aspect,
    and, "The Charter". Each Usenet group has a little charter,
    and used to be each one had a little "Frequently Asked Questions",
    or the culture, for others it's just a feed.


    Now if you'll excuse I'll go rake a leaf or wash a dish or something,
    or maybe organize my closet or or take a pick-axe to a road somewhere,
    yet, probably instead I might be further asking, or, telling, what
    sorts of accounts go into modular software in C.


    The basic idea for that is sort of an account of functions,
    callback-functions, and data, in the language, what's to result models
    of co-operation, about how to call various code _inside_ the runtime, vis-a-vis, various code calling _into_ the runtime, basically mirroring
    the concerns of library authors, of component authors, basically here introducing libraries vis-a-vis components, which is about as old of
    a way of looking at matters of modularity & composability as has always
    been.



    This message will have a permanent, unique ID, when it's published.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Sat Nov 14 09:05:46 2026
    On 11/12/2026 01:44 PM, Ross Finlayson wrote:
    On 11/12/2026 12:55 PM, Richard Harnden wrote:
    On 12/11/2026 20:11, Lew Pitcher wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of
    inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes >>>> and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me.

    Could you rephrase your question without the academic wording?


    Or get an AI do to your homework?

    Be careful to remove the white-on-white-very-small-font gotcha your
    professor doubtlessly put in.




    When I use "A.I." it's framed as a dialogue and I just copy the
    transcripts directly, with the attributions.

    I.e., I've never submitted anything to Usenet written by a bot
    on my behalf.


    I'm not sure whether I'd call it "distance learning", or,
    "distance learning", say, ....




    Like say for example I'm looking at something like this that I tapped
    up this morning, and I want to figure out then how to make it so that
    the guts of the workers have a nice real quality of covering all the
    bases of covering all the cases, when for example according to the C
    host as it were or POSIX there's signals and traps to be figured out
    in accounts of "asynchronous concurrency".






    Outline of "I/O-handle-bound process model"

    The "I/O-handle-bound process model", is an account of a process group
    in a process tree,
    that works up to the bounds of 1024 many file-descriptors that a
    pselect() call can poll,
    with up to 1000-many file-descriptors in up to 1000-many worker
    processes, for up to
    1,000,000-many open connections.

    The "1000-many" is basically derived from FD_SETSIZE having a limit of
    1024,
    and that numbered file-descriptors that can participate in non-blocking I/O with pselect() notification of readiness, must be less than FD_SETSIZE
    their value.

    The basic idea is that there's a main or master process, that being also
    the process group leader,
    that has a "process-protocol" convention, that the master/leader, has
    domain sockets
    to its child processes, with up to 1000-many worker processes, then
    other processes
    as the listener, which accepts connections, and a logger and a metrics process.

    The listener is its own process that does accept and management (figured
    IP address listing and perhaps a tiny bit of TLS business). It's figured
    that it's
    an Internet protocol server, and "connection-oriented", or as mostly
    about TCP/IP,
    and furthermore "association-oriented", about SCTP, then about UDP or datagram
    "protocols", the listener demultiplexes the packets as "connections" to
    the workers.

    The file-descriptors in a process are numbered, non-negative integers.

    The file-descriptors 0, 1, 2 are ubiqitously stdin, stdout, stderr,
    "standard input-output-error".

    The file-descriptor 3 is reserved as it may be a convention for passing
    open connections to created processes.

    The file-descriptors 4, 5, 6 are reserved as "stdlog, stdmet, stddmp", "logging-metrics-dump outputs".

    The file-descriptors 21-1020 are reserved for "1000-many connections".

    The leader uses the "1000-many connections" for domain sockets to its "1000-many workers".

    Each follower (listener, worker, ...) has a reserved file-descriptor
    (11) to connect with the leader.

    The leader uses file-descriptor 11 to connect to the listener.
    The leader uses file-descriptor 12 to connect to an optional console.
    The leader uses file-descriptor 13 to connect to an optional logger.
    The leader uses file-descriptor 14 to connect to an optional metrics.

    launcher

    leader

    logger
    metrics
    console

    listener
    worker

    The model of operation describes how a process is created, according to
    fork and execve.

    The file-descriptors 0-10 are "standard", about stdin/stdout/stderr and
    these
    named stdlog/stdmet/stddmp. Usually stdin is un-read, or set to /dev/null. Usually stdout and stderr are inherited (by all child processes) from
    leader.

    The stdlog and stdmet and stddmp are inherited from leader. A usual idea is that these as file-handles may be passed to the leader for example to
    the shell,
    or that usually according to options, the first child processes of the
    leader are
    the logger and metrics, with the logger and metrics receiving all the messages
    on those handles, then the leader and all other processes sharing those handles,
    and all writing the logs and metrics to those same handles. Then, the
    dumper
    is an abstract output stream, outside of logging and metrics and
    standard I/O.

    The file-descriptors 11-20 are in the "process-protocol".

    The file-descriptors 21-1020 of the leader are in the "process-protocol".
    The file-descriptors 21-1020 of the listener are in the "process-protocol". The file-descriptors 21-1020 of the workers are in the "application-protocol".

    The file-descriptor 3 in the listener is the listening socket.
    The file-descriptor 3 may be passed to the leader to be passed to the listener,
    the listening socket.

    leader:
    4 -> stdlog
    5 -> stdmet
    6 -> stddmp
    11 <-> logger
    12 <-> metrics
    13 <-> listener
    14 <-> console
    21-1020 <-> workers

    logger:
    4 <- stdlog
    6 <- stddmp
    11 <-> logger (leader)
    12 <-> metrics

    metrics:
    5 <- stdmet
    11 <-> logger
    12 <-> metrics (leader)


    listener:
    4 -> stdlog
    5 -> stdmet
    6 -> stddmp
    11 <-> logger
    12 <-> metrics
    13 <-> listener (leader)
    14-20 <-> listening socket(s)
    21-1020 <-> workers

    worker:
    4 -> stdlog
    5 -> stdmet
    6 -> stddmp
    11 <-> leader
    13 <-> listener
    21-1020 -> connections (front-end and back-end)

    Each of these has their own "main()" source code and executable,
    with that each is created by leader with fork() then setting the handles respectively, then execve() thus that the child processes start with
    their open handles in the process-protocol (11-20) and stdio (0-10)
    already opened and directed.

    Then, the process-protocol is according to use-cases, as driven by
    events, about that the domain-sockets that are under the handles
    of the process-protocol, make for passing data, and also live handles,
    as are the connections.


    The main use-case is that the listener is bound to a listening socket,
    as connections are accepted with connection-management happening
    in the listener, listener passes the connection to leader, which finds or create a worker, and passes the connection to worker, which then
    proceeds to service the connection according to the application-protocol.

    listener: accepts connection

    listener -> leader: connection-accepted !
    leader -> worker: connection-ready ?
    worker -> leader: connection-ready !
    leader -> listener: pass-ready !
    listener -> leader: connection-pass !
    leader -> worker: connection-pass !

    When a connection is closed, according to the application-protocol
    or if the connection drops or is severed, then worker advises leader,
    then leader advises listener.

    worker -> leader: connection-closed
    leader -> listener: connection-closed

    Then, when there are process-level events, the leader makes
    commands to the workers, about graceful exit.

    leader -> worker: drain connections
    leader -> worker: close connections
    leader -> worker: exit

    Since connections and their attachments & associations
    may be short-lived or long-lived, and the goal is that
    there only needs be as many workers as fulfill servicing
    the connections, then is that there's a process-protocol
    about migrating associations (and their connections)
    among workers, usually from "sparse" workers to "dense"
    workers, where sparse means "not-very-full" and dense
    means "not-very-empty", or from "short-lived" workers
    to "long-lived" workers when connections are long-lived,
    that "association migration" is in the process-protocol.

    leader -> worker: emigrate-association
    worker -> leader: migrate-association
    leader -> worker: immigrate-association


    The threading model in the process model

    The basic idea of the threading model is that workers
    are multi-threaded, the leader is single-threaded, and
    that the threads "park" when there is no activity,
    yet that the workers have one "sweeper" thread
    to account for time-outs, then that as the workers
    close their connections, they exit, so that under no
    traffic, there is no activity, with all processes "parked".

    The idea of "parking" is blocking on the inputs to the
    protocols, or the event-driven pumps in the workers.

    The threads basically block in pselect() waiting for
    ready reading, writing, or other events, or, waiting
    on a queue item, pop().

    The leader parks in pselect() on 11-1024, the process-protocol.

    The listener parks in pselect() about
    accept() and pselect() on the listening socket and
    the process-protocol sockets.

    The worker has four or more threads.

    reader-thread: parks in pselect() with read-interest
    executor-thread: parks in pop() of application-protocol tasks
    writer-thread: parks in pop() of application-protocol responses, then
    blocks in pselect() while writing, then parks
    sweeper-thread: according to time/alarm, runs on a frequency eg 500 milliseconds, 5 seconds, 5 minutes

    When the worker is empty, after its connections close, it exits.

    The logger and metrics park in pselect() on the read-side of stdlog/stdmet/stddmp.

    Thusly, at idle, with no connections, the entire process-group is
    "parked" (0% CPU, "acquiescent").









    So, this sort of account is example, for an idea, of the considerations.

    Why this may be considered "relevant to C", vis-a-vis, say,
    "relevant to platforms & frameworks aboove the system-platform",
    is because C is the ubiquitous relevant standard to systems programming.
    Of course, C is just ubiquitous itself in accounts
    like embedded-programming, here though in a world where all the distributed-programming mostly is defined by standards that, for
    example, as described in books like "TCP/IP Illustrated" and "Network Programming", which outline in detail the implementations of
    internetworking on the Internet, C is the milieu.

    Then, "POSIX" pretty much includes C by convention and practice,
    also defining a wider surface about the runtime. So, since also
    a subset of POSIX runs on anything, here it's considered reasonably
    relevant, unless you know a newsgroup about "modular programming
    of Internet client & server and peer-to-peer platforms & frameworks
    for the modern age in its bog-standard commodity monocultures of
    systems & infrastructure", where it may be more particularly apropos.


    So what this is then is an outline of a world where long-running
    server processes, or for example looking at it the other way
    a massively parallel multi-plexing client for doing jobs,
    that the process-model is in a real world with limited resources,
    albeit then with the guarantees given, the responsibilities & guarantees.


    As you can see from reading it, or, you know, to each their own,
    the idea is that these "leader", "listener", "worker" processes
    would be alike "nntpd-leader", "nntpd-listener", "nntpd-worker",
    with regards to "named and well-known protocols and their well-known
    ports according to practice and the IANA, or for example running
    protocols on 443 since that's the only port not firewalled".

    So, the idea is that a model of a _protocol_, basically has
    bi-directional or duplex communications, about communicating
    sequential processes, these then defined in terms of the abstractions
    of the platform, here "sockets" after "files", and that's the way it
    is, then about moving & copying the data, and interpreting and invoking
    the commands as logical, and establishing and maintaining the protocols,
    since convention and specification and standard and practice.




    Now, lots of people would say, "I can only look at one thing at
    one time, if it's a process it needs to have only one PID so
    that's it". Well, I think so too, it's involved, yet as well,
    that's not the way it is. So, here this "leader" process is
    a mostly tiny process whose role mostly is to get passed a
    privileged port or ports, according to TCP/UDP/SCTP, then that
    it can run as an un-privileged user otherwise with being able
    to bind the privileged port, then it's a tiny process so that
    as it fork()'s to exec/execv/execve or create processes in a
    group of processes so managed, it's only got one-deep ancestry,
    and about how in POSIX it must manage the masks and handlers of
    process signals after "raise", "signal" or "kill", all up and
    down the tree, and that's the way it is. (Another reason to
    have only one process is to keep its quotas & limits and
    monitoring & management a single number, yet that's why it's
    in a process-group, and multiple processes for the "I/O-handle-bound
    process model", which is the way it's possible to scale it up this way,
    about 500K connections.)


    So, that thusly being as of a sort of "library" routine, for example
    that "a shell launches it and redirects its I/O the whole process-group
    how it wants", then the innards or guts, is about, "protocol-modules".
    (The process-group has its own, "process-protocol", otherwise all, "application-protocols".)


    Then, there are communicating-sequential-processes it serves, the
    frontend and, also communicating-sequential-processes its dependencies,
    the back-end, then also accounts of the half-duplex and full-duplex
    what it serves, the client-server and peer-to-peer.



    So, then for "libraries", and, "think like a library author" and
    these kinds of things, is, "components", and, "think like a component
    framework provider".



    The implementors of protocols _need not care_ about the runtime of them,
    about "a component framework for definition of protocol",
    and, "a component framework of client & server in protocol",
    or, "com-peering in protocol", then about the re-usability of
    the code, in C and not ugly and hot & fast & safe & nice.










    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Sat Nov 14 17:57:50 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    Ross Finlayson pisze:
    On 11/14/2026 05:19 AM, Kenny McCormack wrote:
    In article <11d9jb7$1tt0p$1@dont-email.me>, bartc? <bc@freeuk.com> wrote: >>> On 14/11/2026 08:09, Kenny McCormack wrote:
    In article <11d7fbv$1839o$2@dont-email.me>,
    David Brown? <david.brown@hesbynett.no> 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.

    One word: fir.

    How about Bill Cunningham?



    Not sure I catch the reference, but I do vaguely remember that name being
    someone who used to post here.

    The thing is, though, when you get right down to it, nobody really knows
    why anyone posts here.? I think each person who does does so for personal
    reasons that are in general not fully comprehensible by anyone else.

    Take the classic question: Why does Kenny McCormack post here, when
    all he
    does is troll?? Well, he does it because it is fun and it amuses him.

    But I often ask: Why does KT post here?? Since he obviously knows
    everything there is to know about C, why bother posting here?? It's not
    like he is ever going to learn anything (since he already knows
    everything).? Now, he will say, it is because he wants to help people.
    Well, this motive is already suspect (usually people who say they want to
    help people have some other motive, sometimes in addition to a genuine
    desire to help, but sometimes as the only motive), and, secondly,
    given how
    much effort he puts into it, it is hard to believe that altruism is the
    only reason.

    And you could ask similar questions about just about everyone else who
    posts to Usenet (not just this group) ?

    And so it goes...



    Usenet is like a rather large bulletin-board system of the world,
    though I guess that's what "FIDO Net" is, federated bulletin-boards.
    Usenet has all the trappings the Internet, which it predates, i.e.
    pre-dates not pred-ates, where "predation" and "predating" are two
    different words, though, both I suppose gerunds, point being that Usenet
    has been around since before the Internet, and it has URL's and
    since every message ever posted is designed to have a unique ID,
    then also there are bibiographic citation standards about it,
    which might not mean much except that all the messages are distributed
    in the widely decentralized and available to any, in the public
    availability and not the public domain, as naturally authors maintain copyright of their postings they publish.


    Why people post to Usenet is for whatever reason they want
    and when they do is their own business, though it's rather
    explicitly not-for-commercial-purposes and it's not much
    for me to say how anti-spam works.

    Whether all gerunds end in "-ing" for example, there's a corner
    where once-upon-a-time people with strong opinions would weigh
    the question and merit the weights and politely and eruditely
    argue its alternatives, with great decorum and fine collegiality.

    ... Or flame all day, it's a free country.

    There are moderated groups, most dusty or defunct.


    Then, there are issues about that since the basically return-path
    is email, and email may be fakemail, and not all vectors into Usenet
    care, whether "Kenny McCormack", for example, inspired or mocks
    the character from "Spice Pork", who-made-who, has that it is or isn't
    so, then also that long before "A.I." was shored-up and silo'ed
    behind the more commercial accounts of "social media", there are
    tons bots among the trolls, usually with stolen identities from
    dupes on the Internet who'd never notice, yet of course that sort
    of practice is way more evident in the modern commercial accounts
    of "social media" with the "I.A.: instant audience" of simple
    bot-fan and bot-troll accounts of click-fraud and propagandist spew.


    Then, a key account of the Usenet is the co-operative aspect,
    and, "The Charter". Each Usenet group has a little charter,
    and used to be each one had a little "Frequently Asked Questions",
    or the culture, for others it's just a feed.


    Now if you'll excuse I'll go rake a leaf or wash a dish or something,
    or maybe organize my closet or or take a pick-axe to a road somewhere,
    yet, probably instead I might be further asking, or, telling, what
    sorts of accounts go into modular software in C.


    The basic idea for that is sort of an account of functions, callback-functions, and data, in the language, what's to result models
    of co-operation, about how to call various code _inside_ the runtime, vis-a-vis, various code calling _into_ the runtime, basically mirroring
    the concerns of library authors, of component authors, basically here introducing libraries vis-a-vis components, which is about as old of
    a way of looking at matters of modularity & composability as has always
    been.



    This message will have a permanent, unique ID, when it's published.


    sckets are terribly stupid im this api for sockets should look more like

    //serwer

    FILE* invitation_socket = fopen("194.122.212.32", "i");

    while(HowManyClientsWantToJoin()>0)
    {
    CLIENT_DATA* = GetWaitingClientData(invitation_socket );
    EstablishConnection(CLIENT_DATA)
    }
    /// client

    FILE* main_read = fopen("194.122.212.32", "r");
    FILE* main_write = fopen("194.122.212.32", "w");

    if(HowManyPocketsToTake(main_read )>0)
    {
    POCKET_DATA* GetPocekt(main_read );
    //...use
    }


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Sat Nov 14 18:20:26 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    On 2026-11-14 17:17, Ross Finlayson wrote:
    [...]

    ... Or flame all day, it's a free country.

    The latter, "it's a free country", is something I regularly hear
    as statement, specifically in US movies that also play in the US.

    Usenet, the Internet, etc., being supra-national (or pan-gaea) it
    doesn't quite fit; there's countries [with Internet access] where
    folks would be very reluctant to claim such a statement.

    (Just saying...)

    Janis

    [...]


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Sat Nov 14 10:03:51 2026
    Subject: Re: People who spend lots of energy posting to Usenet - and for what? (Was: Inversion-of-control and dependency-injection in C)

    On 11/14/2026 09:20 AM, Janis Papanagnou wrote:
    On 2026-11-14 17:17, Ross Finlayson wrote:
    [...]

    ... Or flame all day, it's a free country.

    The latter, "it's a free country", is something I regularly hear
    as statement, specifically in US movies that also play in the US.

    Usenet, the Internet, etc., being supra-national (or pan-gaea) it
    doesn't quite fit; there's countries [with Internet access] where
    folks would be very reluctant to claim such a statement.

    (Just saying...)

    Janis

    [...]


    Sure, it's a free country, reflects on something like "The UN
    Declaration on Universal Human Rights", authored mostly by a
    Richard McKeon the great classicist and Aristotle scholar,
    and signed by one of the Roosevelt's.

    The egalitarianism in equal-rights and equal-protections under
    democracy as rule-of-law and historicism as knowing itself is
    very strongly held in many, many places, vis-a-vis Tom Paine
    after Montesquieu (sp.) and Locke since Montaigne, or DesCartes,
    for examples.

    Of course everybody's heard of Malthus & Maslow (sp.), while
    yet there are many and various accounts of will and the freedom of it.

    ("If you don't like it you can get out, ....")



    Thanks for writing.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tristan Wibberley@3:633/10 to All on Sun Nov 15 03:10:08 2026
    On 13/11/2026 13:07, Ross Finlayson wrote:
    On 11/13/2026 04:25 AM, Bonita Montero wrote:
    Am 12.11.2026 um 21:11 schrieb Lew Pitcher:

    Pardon my impertinence, but this sounds like a homework problem to me.
    Mabye that's the joke ! ;-)


    Humor is appreciated since it's part of bonnehomie and good-will,
    it's not a joke. (The "distance learning or distance learning"
    was a joke, about "to learn something" vis-a-vis "to learn somebody",
    yet that's just using humor instead of stronger insults or the
    abject sumbission of the door-mat variety of throwing self under the bus.)

    "I like jokes but this isn't one. Work-from-home was a trick to collect
    data about the population ..." etc.


    C++ it's said is getting reflection added to the giant tower of
    what's become of its language and libraries and idiom shoehorned

    "I read that reflection is being added to the behemoth that the C++
    language and libraries have become ..." etc


    It looks like a "precision" style-transfer has been applied.


    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tristan Wibberley@3:633/10 to All on Sun Nov 15 10:26:26 2026
    On 13/11/2026 22:50, Ross Finlayson wrote:

    So, here's one. Say you got a server process for sockets of the connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.


    For anyone who either doesn't understand that text or doesn't get how
    valuable it is just as a question unanswered: please know that it is super.

    To Ross: nobody using Usenet is going to be able to give an adequate
    answer. Maybe a dozen people on the planet can give such an answer and
    maybe each of a dozen teams of academics could do it with several years
    work.

    Now that IBM, Sun and Oracle are all dead I suppose they all work for
    Google now.

    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Sun Nov 15 12:03:54 2026
    Tristan Wibberley pisze:
    On 13/11/2026 22:50, Ross Finlayson wrote:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and
    receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.


    For anyone who either doesn't understand that text or doesn't get how valuable it is just as a question unanswered: please know that it is super.

    To Ross: nobody using Usenet is going to be able to give an adequate
    answer. Maybe a dozen people on the planet can give such an answer and
    maybe each of a dozen teams of academics could do it with several years
    work.

    ai may answer it in about 10 seconds:


    C does not really need a special component model for this. Most of what
    you describe can be done with a fairly small number of ordinary C
    mechanisms, provided that the boundaries between them are made explicit.

    The important distinction, in my opinion, is between a **source
    module**, a **runtime module**, and an **interface**.

    A `.c` file is a compilation unit, not necessarily a runtime component. Several `.c` files may form one library or runtime component, while one
    `.c` file may contain several logically unrelated things. The actual
    runtime boundary is usually represented by an API and, if necessary, by
    a table of function pointers.

    For example, instead of making an object hierarchy, one can simply define:

    ```c
    struct renderer {
    void (*draw)(struct renderer *, const void *);
    void (*clear)(struct renderer *);
    void (*destroy)(struct renderer *);
    void *context;
    };
    ```

    An implementation constructs such a structure:

    ```c
    struct renderer *CreateSoftwareRenderer(void);
    struct renderer *CreateOpenGLRenderer(void);
    ```

    The rest of the program only knows about `struct renderer` and its
    contract. It does not need to know which implementation was constructed.

    That already gives you a fairly direct form of dependency injection:

    ```c
    struct renderer *renderer = CreateSoftwareRenderer();
    game.renderer = renderer;
    ```

    or, even more explicitly:

    ```c
    game.renderer.draw = SoftwareDraw;
    game.renderer.clear = SoftwareClear;
    game.renderer.destroy = SoftwareDestroy;
    game.renderer.context = &software_state;
    ```

    There is no fundamental requirement that the dependency be discovered globally. It can simply be passed to the code which needs it.

    In fact, I would say that **passing dependencies explicitly is one of
    the most natural forms of dependency injection in C**.

    The same technique works without function pointers when the dependency
    is data rather than behavior. For example:

    ```c
    struct allocator {
    void *(*alloc)(struct allocator *, size_t);
    void (*free)(struct allocator *, void *);
    void *context;
    };
    ```

    Then a subsystem can receive an allocator without knowing whether it ultimately uses `malloc`, a pool, an arena, a debug allocator, or
    something supplied by a test harness.

    This is also where ownership belongs. The interface should state things
    such as:

    ```c
    void *ResourceCreate(...);
    void ResourceDestroy(void *);
    ```

    and document who owns the returned resource and when `Destroy` must be
    called. C has no language-level ownership system, so this is part of the
    API contract rather than something the compiler enforces.

    For test-time versus run-time implementations, I would normally avoid conditional compilation inside the actual application code.

    Instead of:

    ```c
    #ifdef TEST
    ...
    #else
    ...
    #endif
    ```

    I prefer:

    ```c
    struct filesystem {
    int (*read)(struct filesystem *, ...);
    int (*write)(struct filesystem *, ...);
    void *context;
    };
    ```

    and then construct either:

    ```c
    CreateRealFilesystem(...)
    ```

    or:

    ```c
    CreateTestFilesystem(...)
    ```

    The application remains identical.

    Conditional compilation is still useful when the implementations
    themselves genuinely require different platform facilities:

    ```c
    #ifdef _WIN32
    ...
    #elif defined(__linux__)
    ...
    #endif
    ```

    or when selecting which implementation is compiled into a particular target.

    That distinction is useful:

    **conditional compilation chooses code; dependency injection chooses behavior.**

    Build systems then decide which source files participate in a target.

    For example, conceptually:

    ```text
    game
    game.c
    renderer.c
    renderer_software.c

    game_test
    game.c
    renderer.c
    renderer_test.c
    ```

    Both targets can satisfy the same interface, while linking different implementations.

    With static linking, the boundary is mostly a linker boundary. With
    dynamic linking, it can additionally become an operating-system module boundary (`DLL`, `.so`, etc.). The C interface does not fundamentally
    change.

    A DLL can export something as simple as:

    ```c
    struct renderer *CreateRenderer(void);
    ```

    and the host can obtain that symbol dynamically. The ABI then becomes
    part of the contract, which is where things such as calling conventions, structure layout, symbol visibility, versioning, and ownership across
    module boundaries become important.

    There is also no particular reason why every dependency needs to be represented by a huge nested structure of function pointers. That can
    become its own form of accidental object-oriented programming.

    Often this is enough:

    ```c
    struct game {
    struct renderer *renderer;
    struct filesystem *filesystem;
    struct clock *clock;
    };
    ```

    and each interface contains only the operations that actually belong to it.

    This gives you something resembling a manually constructed object graph:

    ```text
    game
    / | \
    / | \
    renderer filesystem clock
    | | |
    software test fake
    ```

    The graph is constructed at startup. The game does not construct its own concrete dependencies; somebody outside it does.

    That is essentially the interesting part of inversion of control in C.

    The phrase "IoC" can sound much more exotic than the mechanism actually
    is. At the simplest level it means:

    Instead of this subsystem deciding what implementation it will use,
    somebody else gives it the implementation.

    Function pointers are one way of doing that. Plain function arguments
    are another, and often the better one.

    For example, a function such as:

    ```c
    void Simulate(struct simulation *s,
    float (*random)(void),
    void (*log)(const char *));
    ```

    is already dependency injection. No component framework is required.

    Likewise, a callback is already a small form of inversion of control:

    ```c
    void EnumerateFiles(const char *path,
    void (*callback)(const char *name, void *context),
    void *context);
    ```

    The library controls the enumeration and calls code supplied by the caller.

    So I would not start by designing "components". I would start by
    identifying **contracts**.

    For each subsystem ask:

    1. What does the caller need to know?
    2. What must remain private?
    3. Who owns the resources?
    4. Which behavior needs to be replaceable?
    5. Does it actually need runtime replacement, or is link-time selection enough?
    6. Does the boundary need to cross a shared-library/ABI boundary?

    Then choose the simplest mechanism:

    ```text
    ordinary function call
    ?
    function parameter / callback
    ?
    context pointer
    ?
    struct containing function pointers
    ?
    separate static library
    ?
    dynamic library / plugin
    ?
    full component framework
    ```

    I would only move down that list when the simpler mechanism stops being sufficient.

    In particular, I would be rather suspicious of reproducing COM in C
    merely because COM solves a problem that C does not have. A table of
    function pointers plus a context pointer is already surprisingly close
    to the essential machinery of an object interface:

    ```c
    struct interface {
    void *context;

    int (*open)(void *context);
    int (*read)(void *context, void *buffer, size_t size);
    void (*close)(void *context);
    };
    ```

    The context provides instance state, the function pointers provide
    polymorphic behavior, and the header defines the contract.

    Multiple interfaces are simply multiple such tables, rather than
    multiple inheritance:

    ```c
    struct device {
    struct input_interface input;
    struct output_interface output;
    struct diagnostic_interface diagnostic;
    };
    ```

    If a component has to support querying for optional interfaces, then
    something resembling `QueryInterface()` can certainly be implemented.
    But again, that is a convention built on ordinary C rather than a
    language feature.

    There is one more important point about "modularity": **the header is
    not necessarily the interface**.

    A good C module often has:

    ```c
    foo.h
    foo.c
    ```

    where `foo.h` exposes the public contract and `foo.c` contains private structures and implementation details.

    For example:

    ```c
    /* foo.h */

    struct foo;

    struct foo *FooCreate(void);
    void FooDestroy(struct foo *);
    int FooDoSomething(struct foo *);
    ```

    while `struct foo` itself is private.

    That gives you opaque state without needing classes:

    ```c
    struct foo {
    int private_state;
    ...
    };
    ```

    The caller can hold a `struct foo *` but cannot depend on its
    representation.

    This is often more valuable for long-term modularity than adding another
    layer of function-pointer indirection.

    So, in short, C has most of the machinery being described here, but it
    is deliberately not packaged into one language-level object/component
    system.

    You have:

    ```text
    .h/.c
    ? source/module boundaries

    opaque structs
    ? encapsulation

    function pointers + context
    ? interfaces / polymorphism

    callbacks
    ? inversion of control

    explicit parameters
    ? dependency injection

    constructors/factory functions
    ? choosing implementations

    static libraries
    ? link-time composition

    shared libraries
    ? runtime composition

    build configuration
    ? selecting implementations

    explicit create/destroy contracts
    ? resource ownership
    ```

    The interesting part is not that C lacks these abstractions. It is that
    **C lets you assemble them yourself**, which means the programmer also
    has to decide where the abstraction is actually justified.

    And that last part is both C's freedom and C's trap.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tristan Wibberley@3:633/10 to All on Sun Nov 15 11:31:18 2026
    On 12/11/2026 23:26, Janis Papanagnou wrote:

    (Disclaimer: my comments are just based on personal experience
    in our software developing practice from the 1990's and not some
    general accepted opinion or habits.)

    How could it be otherwise? With 8 billion people on the planet and
    on-demand media with algorithms capable of segmenting the population's information streams you'd never know what was generally accepted anyway.


    On "writing testable code" he wrote:

    Our approach was not to "write testable code" by _adapting_ to
    some existing framework. While we had standards and practices how
    to design software the _tests followed our software_ (not v.v.).
    One exception here was that including dedicated trace records in
    our code (that could be activated specifically WRT a module and
    in granularity) helped for the test evaluation and regressions.

    I don't really understand test trace records. It seems to me that to
    test whether certain thresholds are reached one ought to use some sort
    of COMEFROM targetting the notification call that marks said threshold
    within the program anyway - the call that triggers the real program's
    response to the threshold being breached.

    If one adds special trace markers the markers may drift away from the notification as development progresses but the real notification is all
    that's needed in the code. If necessary run unit tests under a debugger
    with a trap on the notification call to implement COMEFROM.

    The use of data instead of such callbacks has its uses in some places
    such as when the program is mapping data and the test will be
    data-driven - one datum or one partial leading sequence of the data can
    get a record output but then it should normally be percolated from the
    inside of the program using real notification calls.


    (See my comment about "tests follow code (not v.v.)". - Opinions may
    differ.)

    Tests that follow code might be good to test for operational change but
    good unit testing tests against semantic intent (even though the intent
    has been tempered by operational limits by the time the design has been
    reduced to unit interfaces), those tests /can't/ follow code. Granted
    it's hard to design without coding, but the interface typically ought to abstract the operations fully even when you've analysed your intent by codestorming.

    If all the tests follow code directly then semantic intent isn't tested.

    It's also a problem for making sure technical documentation is accurate
    because the best way to be sure it is is to write it against test passes.



    --
    Tristan Wibberley

    The message body is Copyright (C) 2026 Tristan Wibberley except
    citations and quotations noted. All Rights Reserved except that you may,
    of course, cite it academically giving credit to me, distribute it
    verbatim as part of a usenet system or its archives, and use it to
    promote my greatness and general superiority without misrepresentation
    of my opinions other than my opinion of my greatness and general
    superiority which you _may_ misrepresent. You definitely MAY NOT train
    any production AI system with it but you may train experimental AI that
    will only be used for evaluation of the AI methods it implements.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Sun Nov 15 12:43:38 2026
    fir pisze:
    Tristan Wibberley pisze:
    On 13/11/2026 22:50, Ross Finlayson wrote:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and
    receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.


    For anyone who either doesn't understand that text or doesn't get how
    valuable it is just as a question unanswered: please know that it is
    super.

    To Ross: nobody using Usenet is going to be able to give an adequate
    answer. Maybe a dozen people on the planet can give such an answer and
    maybe each of a dozen teams of academics could do it with several years
    work.

    ai may answer it in about 10 seconds:


    C does not really need a special component model for this. Most of what
    you describe can be done with a fairly small number of ordinary C mechanisms, provided that the boundaries between them are made explicit.

    The important distinction, in my opinion, is between a **source
    module**, a **runtime module**, and an **interface**.

    A `.c` file is a compilation unit, not necessarily a runtime component. Several `.c` files may form one library or runtime component, while one
    `.c` file may contain several logically unrelated things. The actual
    runtime boundary is usually represented by an API and, if necessary, by
    a table of function pointers.

    For example, instead of making an object hierarchy, one can simply define:

    ```c
    struct renderer {
    ˙˙˙ void (*draw)(struct renderer *, const void *);
    ˙˙˙ void (*clear)(struct renderer *);
    ˙˙˙ void (*destroy)(struct renderer *);
    ˙˙˙ void *context;
    };
    ```

    An implementation constructs such a structure:

    ```c
    struct renderer *CreateSoftwareRenderer(void);
    struct renderer *CreateOpenGLRenderer(void);
    ```

    The rest of the program only knows about `struct renderer` and its
    contract. It does not need to know which implementation was constructed.

    That already gives you a fairly direct form of dependency injection:

    ```c
    struct renderer *renderer = CreateSoftwareRenderer();
    game.renderer = renderer;
    ```

    or, even more explicitly:

    ```c
    game.renderer.draw = SoftwareDraw;
    game.renderer.clear = SoftwareClear;
    game.renderer.destroy = SoftwareDestroy;
    game.renderer.context = &software_state;
    ```

    There is no fundamental requirement that the dependency be discovered globally. It can simply be passed to the code which needs it.

    In fact, I would say that **passing dependencies explicitly is one of
    the most natural forms of dependency injection in C**.

    The same technique works without function pointers when the dependency
    is data rather than behavior. For example:

    ```c
    struct allocator {
    ˙˙˙ void *(*alloc)(struct allocator *, size_t);
    ˙˙˙ void (*free)(struct allocator *, void *);
    ˙˙˙ void *context;
    };
    ```

    Then a subsystem can receive an allocator without knowing whether it ultimately uses `malloc`, a pool, an arena, a debug allocator, or
    something supplied by a test harness.

    This is also where ownership belongs. The interface should state things
    such as:

    ```c
    void *ResourceCreate(...);
    void ResourceDestroy(void *);
    ```

    and document who owns the returned resource and when `Destroy` must be called. C has no language-level ownership system, so this is part of the
    API contract rather than something the compiler enforces.

    For test-time versus run-time implementations, I would normally avoid conditional compilation inside the actual application code.

    Instead of:

    ```c
    #ifdef TEST
    ˙˙˙ ...
    #else
    ˙˙˙ ...
    #endif
    ```

    I prefer:

    ```c
    struct filesystem {
    ˙˙˙ int (*read)(struct filesystem *, ...);
    ˙˙˙ int (*write)(struct filesystem *, ...);
    ˙˙˙ void *context;
    };
    ```

    and then construct either:

    ```c
    CreateRealFilesystem(...)
    ```

    or:

    ```c
    CreateTestFilesystem(...)
    ```

    The application remains identical.

    Conditional compilation is still useful when the implementations
    themselves genuinely require different platform facilities:

    ```c
    #ifdef _WIN32
    ˙˙˙ ...
    #elif defined(__linux__)
    ˙˙˙ ...
    #endif
    ```

    or when selecting which implementation is compiled into a particular
    target.

    That distinction is useful:

    **conditional compilation chooses code; dependency injection chooses behavior.**

    Build systems then decide which source files participate in a target.

    For example, conceptually:

    ```text
    game
    ˙˙˙ game.c
    ˙˙˙ renderer.c
    ˙˙˙ renderer_software.c

    game_test
    ˙˙˙ game.c
    ˙˙˙ renderer.c
    ˙˙˙ renderer_test.c
    ```

    Both targets can satisfy the same interface, while linking different implementations.

    With static linking, the boundary is mostly a linker boundary. With
    dynamic linking, it can additionally become an operating-system module boundary (`DLL`, `.so`, etc.). The C interface does not fundamentally change.

    A DLL can export something as simple as:

    ```c
    struct renderer *CreateRenderer(void);
    ```

    and the host can obtain that symbol dynamically. The ABI then becomes
    part of the contract, which is where things such as calling conventions, structure layout, symbol visibility, versioning, and ownership across
    module boundaries become important.

    There is also no particular reason why every dependency needs to be represented by a huge nested structure of function pointers. That can
    become its own form of accidental object-oriented programming.

    Often this is enough:

    ```c
    struct game {
    ˙˙˙ struct renderer *renderer;
    ˙˙˙ struct filesystem *filesystem;
    ˙˙˙ struct clock *clock;
    };
    ```

    and each interface contains only the operations that actually belong to it.

    This gives you something resembling a manually constructed object graph:

    ```text
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ game
    ˙˙˙˙˙˙˙˙˙˙˙˙˙ /˙˙ |˙˙˙ \
    ˙˙˙˙˙˙˙˙˙˙˙˙ /˙˙˙ |˙˙˙˙ \
    ˙˙˙˙˙˙ renderer filesystem clock
    ˙˙˙˙˙˙˙˙˙ |˙˙˙˙˙˙˙˙˙ |˙˙˙˙˙˙ |
    ˙˙˙˙˙ software˙˙˙˙ test˙˙˙ fake
    ```

    The graph is constructed at startup. The game does not construct its own concrete dependencies; somebody outside it does.

    That is essentially the interesting part of inversion of control in C.

    The phrase "IoC" can sound much more exotic than the mechanism actually
    is. At the simplest level it means:

    Instead of this subsystem deciding what implementation it will use,
    somebody else gives it the implementation.

    Function pointers are one way of doing that. Plain function arguments
    are another, and often the better one.

    For example, a function such as:

    ```c
    void Simulate(struct simulation *s,
    ˙˙˙˙˙˙˙˙˙˙˙˙˙ float (*random)(void),
    ˙˙˙˙˙˙˙˙˙˙˙˙˙ void (*log)(const char *));
    ```

    is already dependency injection. No component framework is required.

    Likewise, a callback is already a small form of inversion of control:

    ```c
    void EnumerateFiles(const char *path,
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ void (*callback)(const char *name, void *context),
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ void *context);
    ```

    The library controls the enumeration and calls code supplied by the caller.

    So I would not start by designing "components". I would start by
    identifying **contracts**.

    For each subsystem ask:

    1. What does the caller need to know?
    2. What must remain private?
    3. Who owns the resources?
    4. Which behavior needs to be replaceable?
    5. Does it actually need runtime replacement, or is link-time selection enough?
    6. Does the boundary need to cross a shared-library/ABI boundary?

    Then choose the simplest mechanism:

    ```text
    ordinary function call
    ˙˙˙˙˙˙˙ ?
    function parameter / callback
    ˙˙˙˙˙˙˙ ?
    context pointer
    ˙˙˙˙˙˙˙ ?
    struct containing function pointers
    ˙˙˙˙˙˙˙ ?
    separate static library
    ˙˙˙˙˙˙˙ ?
    dynamic library / plugin
    ˙˙˙˙˙˙˙ ?
    full component framework
    ```

    I would only move down that list when the simpler mechanism stops being sufficient.

    In particular, I would be rather suspicious of reproducing COM in C
    merely because COM solves a problem that C does not have. A table of function pointers plus a context pointer is already surprisingly close
    to the essential machinery of an object interface:

    ```c
    struct interface {
    ˙˙˙ void *context;

    ˙˙˙ int˙ (*open)(void *context);
    ˙˙˙ int˙ (*read)(void *context, void *buffer, size_t size);
    ˙˙˙ void (*close)(void *context);
    };
    ```

    The context provides instance state, the function pointers provide polymorphic behavior, and the header defines the contract.

    Multiple interfaces are simply multiple such tables, rather than
    multiple inheritance:

    ```c
    struct device {
    ˙˙˙ struct input_interface input;
    ˙˙˙ struct output_interface output;
    ˙˙˙ struct diagnostic_interface diagnostic;
    };
    ```

    If a component has to support querying for optional interfaces, then something resembling `QueryInterface()` can certainly be implemented.
    But again, that is a convention built on ordinary C rather than a
    language feature.

    There is one more important point about "modularity": **the header is
    not necessarily the interface**.

    A good C module often has:

    ```c
    foo.h
    foo.c
    ```

    where `foo.h` exposes the public contract and `foo.c` contains private structures and implementation details.

    For example:

    ```c
    /* foo.h */

    struct foo;

    struct foo *FooCreate(void);
    void FooDestroy(struct foo *);
    int FooDoSomething(struct foo *);
    ```

    while `struct foo` itself is private.

    That gives you opaque state without needing classes:

    ```c
    struct foo {
    ˙˙˙ int private_state;
    ˙˙˙ ...
    };
    ```

    The caller can hold a `struct foo *` but cannot depend on its representation.

    This is often more valuable for long-term modularity than adding another layer of function-pointer indirection.

    So, in short, C has most of the machinery being described here, but it
    is deliberately not packaged into one language-level object/component system.

    You have:

    ```text
    .h/.c
    ˙˙˙ ? source/module boundaries

    opaque structs
    ˙˙˙ ? encapsulation

    function pointers + context
    ˙˙˙ ? interfaces / polymorphism

    callbacks
    ˙˙˙ ? inversion of control

    explicit parameters
    ˙˙˙ ? dependency injection

    constructors/factory functions
    ˙˙˙ ? choosing implementations

    static libraries
    ˙˙˙ ? link-time composition

    shared libraries
    ˙˙˙ ? runtime composition

    build configuration
    ˙˙˙ ? selecting implementations

    explicit create/destroy contracts
    ˙˙˙ ? resource ownership
    ```

    The interesting part is not that C lacks these abstractions. It is that
    **C lets you assemble them yourself**, which means the programmer also
    has to decide where the abstraction is actually justified.

    And that last part is both C's freedom and C's trap.


    note i dont personally use this above approch

    generally i write a program when its verious parts are vaguelly
    dependant... its not necessary good and i think more recently about this pinpoints

    coz parts of program together may bring a mess
    for example in my rasterizer/shoter 3d game prototype there is
    general window part (which reads keyboard uses some kays and also "uses hud"..and inner 3d game part which also uses keyboard/mouse and hud

    it generates some mess poteintially..especially as 1 i need to manage
    some states like 2d/3d mode of window, yet two modes of camera in 3d
    mode - states become to born mess..other problem is various parts ot
    this 3d game may use those keys and hud and so,etimes it become hard to
    find ehere is what..yet i got a problem with fainding some functions sometimes..as sometimes some tiny usefull functions may belong to some modules/files but they belonging is not so obvious so if such function
    can be in five places you will notice a serious hangout in your head
    localizing it

    its sometimes good to make "hard split" and put one part into dll
    but managing this dll is slightly more burdensome than having it all
    together so i probably prefer make this split in more heavier cases only
    (im not yet quite sure - before i used dll long time, only recently in
    case of revriting things i redigned the dll..and now i both slightly
    miss it and possibly somewhat less slightly dont miss it (miss its good
    side dont miss its bad side)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 16:23:23 2026
    Am 12.11.2026 um 21:15 schrieb Chris M. Thomasson:

    C is C. Imvvvvho, C++ is better... :^) Let the flames begin.

    A frequently cited point in this context is that `std::sort()` is
    typically many times faster than `qsort()`, thanks to the inlining
    of the function object. Furthermore, a function object can easily
    incorporate an external context by capturing it within a lambda?
    something that is simply not possible with `qsort()`, where a C
    -style comparison function is restricted to accessing only global
    variables. This falls far short of the capabilities offered by
    functional programming. In other words: C is incapable of func-
    tional programming.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 16:29:39 2026
    Bonita Montero pisze:
    Am 12.11.2026 um 21:15 schrieb Chris M. Thomasson:

    C is C. Imvvvvho, C++ is better... :^) Let the flames begin.

    A frequently cited point in this context is that `std::sort()` is
    typically many times faster than `qsort()`, thanks to the inlining
    of the function object. Furthermore, a function object can easily
    incorporate an external context by capturing it within a lambda?
    something that is simply not possible with `qsort()`, where a C
    -style comparison function is restricted to accessing only global
    variables. This falls far short of the capabilities offered by
    functional programming. In other words: C is incapable of func-
    tional programming.

    you can write you own sort or paste if trom the net and its not worse
    than c++

    in some thread on this as maybe you remember i taka a contest ;c on c++
    sort and beat it much (as far as i remember by code taken from net)


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 16:35:58 2026
    fir pisze:
    Bonita Montero pisze:
    Am 12.11.2026 um 21:15 schrieb Chris M. Thomasson:

    C is C. Imvvvvho, C++ is better... :^) Let the flames begin.

    A frequently cited point in this context is that `std::sort()` is
    typically many times faster than `qsort()`, thanks to the inlining
    of the function object. Furthermore, a function object can easily
    incorporate an external context by capturing it within a lambda?
    something that is simply not possible with `qsort()`, where a C
    -style comparison function is restricted to accessing only global
    variables. This falls far short of the capabilities offered by
    functional programming. In other words: C is incapable of func-
    tional programming.

    you can write you own sort or paste if trom the net and its not worse
    than c++

    in some thread on this as maybe you remember i taka a contest ;c on c++
    sort and beat it much (as far as i remember by code taken from net)

    my own quote from google groups

    "
    fir
    23 kwi 2022, 12:35:57
    do
    try radix sort, i once measured that things (on 10-yo old machine) and
    testing sorting 1MB of integers and remember c quicksort (like that from wikipedia) have 150 ms , c++ std:sort 111 ms,
    c insertsort 111 ms also or 2 ms worse something like that, c-radix sort (taken from stack overflow) 17 ms beating c++:stdsort more than 3 times
    for more details search "quicksort" in this group (the search in google
    groups work).."

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 16:38:25 2026
    fir pisze:
    fir pisze:
    Bonita Montero pisze:
    Am 12.11.2026 um 21:15 schrieb Chris M. Thomasson:

    C is C. Imvvvvho, C++ is better... :^) Let the flames begin.

    A frequently cited point in this context is that `std::sort()` is
    typically many times faster than `qsort()`, thanks to the inlining
    of the function object. Furthermore, a function object can easily
    incorporate an external context by capturing it within a lambda?
    something that is simply not possible with `qsort()`, where a C
    -style comparison function is restricted to accessing only global
    variables. This falls far short of the capabilities offered by
    functional programming. In other words: C is incapable of func-
    tional programming.

    you can write you own sort or paste if trom the net and its not worse
    than c++

    in some thread on this as maybe you remember i taka a contest ;c on c++
    sort and beat it much (as far as i remember by code taken from net)

    my own quote from google groups

    "
    fir
    23 kwi 2022, 12:35:57
    do
    try radix sort, i once measured that things (on 10-yo old machine) and testing sorting 1MB of integers and remember c quicksort (like that from wikipedia) have 150 ms , c++ std:sort 111 ms,
    c insertsort 111 ms also or 2 ms worse something like that, c-radix sort (taken from stack overflow) 17 ms beating c++:stdsort more than 3 times
    for more details search "quicksort" in this group (the search in google groups work).."

    see here
    https://groups.google.com/g/comp.lang.c/c/I4lJSh45EJ0/m/ezGwgnvWDgAJ

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 16:39:03 2026
    fir pisze:
    fir pisze:
    fir pisze:
    Bonita Montero pisze:
    Am 12.11.2026 um 21:15 schrieb Chris M. Thomasson:

    C is C. Imvvvvho, C++ is better... :^) Let the flames begin.

    A frequently cited point in this context is that `std::sort()` is
    typically many times faster than `qsort()`, thanks to the inlining
    of the function object. Furthermore, a function object can easily
    incorporate an external context by capturing it within a lambda?
    something that is simply not possible with `qsort()`, where a C
    -style comparison function is restricted to accessing only global
    variables. This falls far short of the capabilities offered by
    functional programming. In other words: C is incapable of func-
    tional programming.

    you can write you own sort or paste if trom the net and its not worse
    than c++

    in some thread on this as maybe you remember i taka a contest ;c on c++
    sort and beat it much (as far as i remember by code taken from net)

    my own quote from google groups

    "
    fir
    23 kwi 2022, 12:35:57
    do
    try radix sort, i once measured that things (on 10-yo old machine) and
    testing sorting 1MB of integers and remember c quicksort (like that
    from wikipedia) have 150 ms , c++ std:sort 111 ms,
    c insertsort 111 ms also or 2 ms worse something like that, c-radix
    sort (taken from stack overflow) 17 ms beating c++:stdsort more than 3
    times
    for more details search "quicksort" in this group (the search in
    google groups work).."

    see here https://groups.google.com/g/comp.lang.c/c/I4lJSh45EJ0/m/ezGwgnvWDgAJ

    lame c++ bonita

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 17:31:00 2026
    I wrote a comparison between std::sort() and qsort() to sort an array of
    4096 ints (fits in L1). On my Zen4-PC std::sort() is 4.8 times faster.
    Any question ?

    #include <iostream>
    #include <algorithm>
    #include <cstdlib>
    #include <chrono>
    #include <vector>
    #include <random>

    using namespace std;
    using namespace chrono;

    int main()
    {
    constexpr size_t
    N = 0x1000,
    Rounds = 10'000;
    auto test = []( auto fn ) -> double
    {
    time_point start = steady_clock::now();
    for( size_t r = Rounds; r; --r )
    fn();
    duration dur = steady_clock::now() - start;
    return (double)duration_cast<nanoseconds>( dur ).count();
    };
    vector<int>
    origin( N ),
    srt( N );
    mt19937_64 mt;
    for( int &i : origin )
    i = (int)mt();
    int dummy = 0;
    auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin() ); dummy += srt[0]; };
    double tRef = test( cpy );
    auto qsrt = [&]
    {
    cpy();
    qsort( srt.data(), srt.size(), sizeof( int ), +[]( const void *lhs,
    const void *rhs ) -> int
    {
    int &iLhs = *(int *)lhs, &iRhs = *(int *)rhs;
    if( iLhs == iRhs )
    return 0;
    return iLhs < iRhs ? -1 : 1;
    } );
    dummy += srt[0];
    };
    double tQsrt = test( qsrt ) - tRef;
    auto stdSrt = [&]
    {
    cpy();
    sort( srt.begin(), srt.end(), less() );
    dummy += srt[0];
    };
    double tStdSrt = test( stdSrt ) - tRef;
    cout << tQsrt / tStdSrt << endl;
    return dummy;
    }



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 17:32:45 2026
    Am 16.11.2026 um 16:39 schrieb fir:

    fir pisze:

    see here https://groups.google.com/g/comp.lang.c/c/I4lJSh45EJ0/m/
    ezGwgnvWDgAJ

    lame c++ bonita

    See my other post - you suck !

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 18:00:01 2026
    Bonita Montero pisze:
    I wrote a comparison between std::sort() and qsort() to sort an array of
    4096 ints (fits in L1). On my Zen4-PC std::sort() is 4.8 times faster.
    Any question ?

    #include <iostream>
    #include <algorithm>
    #include <cstdlib>
    #include <chrono>
    #include <vector>
    #include <random>

    using namespace std;
    using namespace chrono;

    int main()
    {
    ˙˙˙˙constexpr size_t
    ˙˙˙˙˙˙˙ N = 0x1000,
    ˙˙˙˙˙˙˙ Rounds = 10'000;
    ˙˙˙˙auto test = []( auto fn ) -> double
    ˙˙˙˙{
    ˙˙˙˙˙˙˙ time_point start = steady_clock::now();
    ˙˙˙˙˙˙˙ for( size_t r = Rounds; r; --r )
    ˙˙˙˙˙˙˙˙˙˙˙ fn();
    ˙˙˙˙˙˙˙ duration dur = steady_clock::now() - start;
    ˙˙˙˙˙˙˙ return (double)duration_cast<nanoseconds>( dur ).count();
    ˙˙˙˙};
    ˙˙˙˙vector<int>
    ˙˙˙˙˙˙˙ origin( N ),
    ˙˙˙˙˙˙˙ srt( N );
    ˙˙˙˙mt19937_64 mt;
    ˙˙˙˙for( int &i : origin )
    ˙˙˙˙˙˙˙ i = (int)mt();
    ˙˙˙˙int dummy = 0;
    ˙˙˙˙auto cpy = [&] { copy( origin.begin(), origin.end(), srt.begin() ); dummy += srt[0]; };
    ˙˙˙˙double tRef = test( cpy );
    ˙˙˙˙auto qsrt = [&]
    ˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙ cpy();
    ˙˙˙˙˙˙˙˙˙˙˙ qsort( srt.data(), srt.size(), sizeof( int ), +[]( const
    void *lhs, const void *rhs ) -> int
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ int &iLhs = *(int *)lhs, &iRhs = *(int *)rhs;
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ if( iLhs == iRhs )
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ return 0;
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ return iLhs < iRhs ? -1 : 1;
    ˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ } );
    ˙˙˙˙˙˙˙˙˙˙˙ dummy += srt[0];
    ˙˙˙˙˙˙˙ };
    ˙˙˙˙double tQsrt = test( qsrt ) - tRef;
    ˙˙˙˙auto stdSrt = [&]
    ˙˙˙˙˙˙˙ {
    ˙˙˙˙˙˙˙˙˙˙˙ cpy();
    ˙˙˙˙˙˙˙˙˙˙˙ sort( srt.begin(), srt.end(), less() );
    ˙˙˙˙˙˙˙˙˙˙˙ dummy += srt[0];
    ˙˙˙˙˙˙˙ };
    ˙˙˙˙double tStdSrt = test( stdSrt ) - tRef;
    ˙˙˙˙cout << tQsrt / tStdSrt << endl;
    ˙˙˙˙return dummy;
    }


    so maybe try it right c way




    typedef unsigned int UI32;

    UI32 * RadixSortUnsigned(UI32 * pData, UI32 * pTemp, size_t count)
    {
    size_t mIndex[4][256] = {0}; // index matrix
    UI32 *pDst, *pSrc, *pTmp;
    size_t i,j,m,n;
    UI32 u;

    for(i = 0; i < count; i++){ // generate histograms
    u = pData[i];
    for(j = 0; j < 4; j++){
    mIndex[j][(size_t)(u & 0xff)]++;
    u >>= 8;
    }
    }
    for(j = 0; j < 4; j++){ // convert to indices
    n = 0;
    for(i = 0; i < 256; i++){
    m = mIndex[j][i];
    mIndex[j][i] = n;
    n += m;
    }
    }
    pDst = pTemp; // radix sort
    pSrc = pData;
    for(j = 0; j < 4; j++){
    for(i = 0; i < count; i++){
    u = pSrc[i];
    m = (size_t)(u >> (j<<3)) & 0xff;
    pDst[mIndex[j][m]++] = u;
    }
    pTmp = pSrc;
    pSrc = pDst;
    pDst = pTmp;
    }
    return(pSrc);
    }


    typedef int I32;
    typedef unsigned int UI32;

    I32 * RadixSortSigned(I32 * pData, I32 * pTemp, size_t count)
    {
    size_t mIndex[4][256] = {0}; // index matrix
    UI32 *pDst, *pSrc, *pTmp;
    size_t i,j,m,n;
    UI32 u;

    for(i = 0; i < count; i++){ // generate histograms
    u = pData[i];
    for(j = 0; j < 4; j++){
    if(j != 3) // signed integer handling
    mIndex[j][(size_t)(u & 0xff)]++;
    else
    mIndex[j][(size_t)((u^0x80) & 0xff)]++;
    u >>= 8;
    }
    }
    for(j = 0; j < 4; j++){ // convert to indices
    n = 0;
    for(i = 0; i < 256; i++){
    m = mIndex[j][i];
    mIndex[j][i] = n;
    n += m;
    }
    }
    pDst = (UI32 *)pTemp; // radix sort
    pSrc = (UI32 *)pData;
    for(j = 0; j < 4; j++){
    for(i = 0; i < count; i++){
    u = pSrc[i];
    if(j != 3) // signed integer handling
    m = (size_t)(u >> (j<<3)) & 0xff;
    else
    m = (size_t)((u >> (j<<3))^0x80) & 0xff;
    pDst[mIndex[j][m]++] = u;
    }
    pTmp = pSrc;
    pSrc = pDst;
    pDst = pTmp;
    }
    return((I32 *)pSrc);
    }



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 18:04:56 2026
    Am 16.11.2026 um 18:00 schrieb fir:

    so maybe try it right c way
    Do you want to compare C vs. C++ or algorithm A vs. algorithm B ?
    The point was that C++ is more convenient and faster than C through
    functional programming when using functional programming with both
    languages; as far as the C-solution can be called functional (I
    wouldn't call it so). And as I've shown the std::sort() leads to
    about six times less code than qsort().


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 18:24:28 2026
    Bonita Montero pisze:
    Am 16.11.2026 um 18:00 schrieb fir:

    so maybe try it right c way
    Do you want to compare C vs. C++ or algorithm A vs. algorithm B ?
    The point was that C++ is more convenient and faster than C through functional programming when using functional programming with both
    languages; as far as the C-solution can be called functional (I
    wouldn't call it so). And as I've shown the std::sort() leads to
    about six times less code than qsort().


    i compare you and myself... you compere your own shilt choice of qsort
    (which only lame coders would take..surprise! bonita took it! sith lame std::sort which only lame c++ crowd could take..surprise again)


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 18:29:09 2026
    Am 16.11.2026 um 18:24 schrieb fir:

    i compare you and myself...
    The discussion was about functional programming in either languagage
    with comparable algorithms. Not about algorithm A in language X vs.
    algorithm B in language Y.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Mon Nov 16 09:35:44 2026
    On 11/14/2026 09:05 AM, Ross Finlayson wrote:
    On 11/12/2026 01:44 PM, Ross Finlayson wrote:
    On 11/12/2026 12:55 PM, Richard Harnden wrote:
    On 12/11/2026 20:11, Lew Pitcher wrote:
    On Thu, 12 Nov 2026 09:41:04 -0800, Ross Finlayson wrote:

    Hello, dear C experts, I'm hoping you can tell me a story about
    modularity and composability, about the concerns of
    inversion-of-control
    and dependency-injection in C, basically about wiring
    test-time and run-time targets, for example about conditional-includes >>>>> and various build-targets, probably mostly about function pointers.

    Pardon my impertinence, but this sounds like a homework problem to me. >>>>
    Could you rephrase your question without the academic wording?


    Or get an AI do to your homework?

    Be careful to remove the white-on-white-very-small-font gotcha your
    professor doubtlessly put in.




    When I use "A.I." it's framed as a dialogue and I just copy the
    transcripts directly, with the attributions.

    I.e., I've never submitted anything to Usenet written by a bot
    on my behalf.


    I'm not sure whether I'd call it "distance learning", or,
    "distance learning", say, ....




    Like say for example I'm looking at something like this that I tapped
    up this morning, and I want to figure out then how to make it so that
    the guts of the workers have a nice real quality of covering all the
    bases of covering all the cases, when for example according to the C
    host as it were or POSIX there's signals and traps to be figured out
    in accounts of "asynchronous concurrency".






    Outline of "I/O-handle-bound process model"

    The "I/O-handle-bound process model", is an account of a process group
    in a process tree,
    that works up to the bounds of 1024 many file-descriptors that a
    pselect() call can poll,
    with up to 1000-many file-descriptors in up to 1000-many worker
    processes, for up to
    1,000,000-many open connections.
    [ ... ]


    I posted another long and discursive bot-chat on comp.theory/comp.unix.programmer about "Portable, Safe,
    Parallel-Semantic Protocol Servers", basically getting into concepts of
    modules and module-ry (like pattern-ry) about config and protocol
    and resource models in a runtime this "I/O-handle-bound process-model"
    of a C11 (C++11-friendly) POSIX-platform framework account of
    "what are modules for componentry about the composable then
    the component-registry and service-discovery for configuration
    the code the process-model of a runtime of a high-performance
    high-reliability re-purposable run-time of protocols and resources".


    I wondered if they had anything to cure OCD yet then I'd figure
    they'd forget it, ....,



    So, this sort of account about C11 (obligatory relevance to
    a discussion about C) of pattern-ry of module-ry (that's a new
    one) of component-ry, mostly is about design, then also about
    the fact that a rather simple and uncomplicated footprint of
    code, is quite most the guts of "the server" (application layer).




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 18:43:40 2026
    Bonita Montero pisze:
    Am 16.11.2026 um 18:24 schrieb fir:

    i compare you and myself...
    The discussion was about functional programming in either languagage
    with comparable algorithms. Not about algorithm A in language X vs.
    algorithm B in language Y.


    note i call you a lame becouse in such kind of opinioons youre lame ans
    spread lame talk.. but mostly i call you a lame becouse of your
    offensive and stuppid atitude to c..so i dont wanted to be pointed i
    "name somewhat lame" its a contextual reaction to some user who dont
    want to learn something - not my 'global' ( not context ) opinion
    (not saying i have or not have any.. im like not much have becouse
    things are context dependant and it looks different in many different contexts) (obviousy in the context of clc bonita is not doin much well)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 18:47:06 2026
    Am 16.11.2026 um 18:43 schrieb fir:

    note i call you a lame becouse in such kind of opinioons youre lame ans spread lame talk..

    And you are shifting to aspects that have nothing to do with the initial discussion.

    Rest unread.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 18:55:19 2026
    Bonita Montero pisze:
    Am 16.11.2026 um 18:43 schrieb fir:

    note i call you a lame becouse in such kind of opinioons youre lame
    ans spread lame talk..

    And you are shifting to aspects that have nothing to do with the initial discussion.

    Rest unread.


    i know lame bonita i dont answer oryginal discusion i just show youre
    very lame in sorting and you talk lame shit


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 18:57:20 2026
    Am 16.11.2026 um 18:55 schrieb fir:
    Bonita Montero pisze:
    Am 16.11.2026 um 18:43 schrieb fir:

    note i call you a lame becouse in such kind of opinioons youre lame
    ans spread lame talk..

    And you are shifting to aspects that have nothing to do with the initial
    discussion.

    Rest unread.


    i know lame bonita i dont answer oryginal discusion i just show youre
    very lame in sorting and you talk lame shit
    You're like fifteen.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 19:08:10 2026
    fir pisze:
    so maybe try it right c way




    typedef unsigned int UI32;

    UI32 * RadixSortUnsigned(UI32 * pData, UI32 * pTemp, size_t count)
    {
    size_t mIndex[4][256] = {0};˙˙˙˙˙˙˙˙˙˙˙ // index matrix
    UI32 *pDst, *pSrc, *pTmp;
    size_t i,j,m,n;
    UI32 u;

    ˙˙˙ for(i = 0; i < count; i++){˙˙˙˙˙˙˙˙ // generate histograms
    ˙˙˙˙˙˙˙ u = pData[i];
    ˙˙˙˙˙˙˙ for(j = 0; j < 4; j++){
    ˙˙˙˙˙˙˙˙˙˙˙ mIndex[j][(size_t)(u & 0xff)]++;
    ˙˙˙˙˙˙˙˙˙˙˙ u >>= 8;
    ˙˙˙˙˙˙˙ }
    ˙˙˙ }
    ˙˙˙ for(j = 0; j < 4; j++){˙˙˙˙˙˙˙˙˙˙˙˙ // convert to indices
    ˙˙˙˙˙˙˙ n = 0;
    ˙˙˙˙˙˙˙ for(i = 0; i < 256; i++){
    ˙˙˙˙˙˙˙˙˙˙˙ m = mIndex[j][i];
    ˙˙˙˙˙˙˙˙˙˙˙ mIndex[j][i] = n;
    ˙˙˙˙˙˙˙˙˙˙˙ n += m;
    ˙˙˙˙˙˙˙ }
    ˙˙˙ }
    ˙˙˙ pDst = pTemp;˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙˙ // radix sort
    ˙˙˙ pSrc = pData;
    ˙˙˙ for(j = 0; j < 4; j++){
    ˙˙˙˙˙˙˙ for(i = 0; i < count; i++){
    ˙˙˙˙˙˙˙˙˙˙˙ u = pSrc[i];
    ˙˙˙˙˙˙˙˙˙˙˙ m = (size_t)(u >> (j<<3)) & 0xff;
    ˙˙˙˙˙˙˙˙˙˙˙ pDst[mIndex[j][m]++] = u;
    ˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙ pTmp = pSrc;
    ˙˙˙˙˙˙˙ pSrc = pDst;
    ˙˙˙˙˙˙˙ pDst = pTmp;
    ˙˙˙ }
    ˙˙˙ return(pSrc);
    }


    not i took this from the net so its not my own code and when i took it i
    dont understood it (i only knew that radix sort may be nbetter and
    std sort form c++ is suposingly lame)..so i measured it 27 ms C vs 111
    ms stdlib C++ ;c

    now i understand it its not so hard first you build histograms for each
    byte of input (if input is 1M you got 4M ++s

    then you transform this histogram into offsets like 0:17 1:32 turns into
    0 17 49...

    then you travel on oryginal input array and use those offsets as movabe
    i mean if you find byte "2" you put it in tab[49]="this number that lasy
    byte is 2" and increase 49 on 50 on next pass you do it on 2nd byte

    so its 4x1MB insertions

    its quite neat and i dont see it yet maybe totally sharop but a abit of
    focus and it can be quite sharply understood (i understand it enough)

    overally it is quite C style algortihm much more than typical sorting

    so it not only beats those sortings but is indeed C style

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Mon Nov 16 19:09:51 2026
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Mon Nov 16 19:10:03 2026
    Bonita Montero pisze:
    Am 16.11.2026 um 18:55 schrieb fir:
    Bonita Montero pisze:
    Am 16.11.2026 um 18:43 schrieb fir:

    note i call you a lame becouse in such kind of opinioons youre lame
    ans spread lame talk..

    And you are shifting to aspects that have nothing to do with the initial >>> discussion.

    Rest unread.


    i know lame bonita i dont answer oryginal discusion i just show youre
    very lame in sorting and you talk lame shit
    You're like fifteen.

    to may friend emo i always said im almost 15 (14.9 maybe, 14.8?) (but
    now i feel old..where are those times i felt like 14)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Mon Nov 16 12:04:28 2026
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and
    receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Mon Nov 16 12:20:40 2026
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and
    receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.




    Why don't they just call std::coroutine "fiber"?



    About asynchronous-concurrency, and, progress without starvation,
    and, parallelism, and task-level parallelism vis-a-vis instruction-level parallelism, the "re-routine" account
    basically makes a model of asynchronous concurrency
    "in the language, well, with a subset of the libraries of
    the language", with "automatic parallelization of independent
    tasks", in a sort of account of framework.

    "Computronomat: the re-routine, a model of co-operative co-routine"


    Anyways I suppose I mentioned that before, the re-routine, ....

    Have I mentioned the re-routine?



    About asynchrony, there's basically that co-operative multithreading,
    requires yield, and, call-backs. This is implicit in many accounts of
    event loops with short-running functions and get tossed back atop
    the event loop queue. Re-routines just implicitly always yield
    when any logical dependency is unsatisfied and it's all callbacks and
    callbacks just re-enter the re-routine.



    Yeah, I know, basta, enough, enough, basta, I know, I know.

    It'd be great to have a model of co-operative co-routine in the
    language, ....



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Mon Nov 16 13:10:49 2026
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and
    receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote, perhaps
    not. Sigh.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Tue Nov 17 01:00:17 2026
    On 11/16/2026 01:10 PM, Chris M. Thomasson wrote:
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and
    receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote, perhaps
    not. Sigh.



    About epoll and dropping reads, it's not the same as io_uring
    which has fixed-sized queues and if it gets full drops those
    in the kernel, it's about the edge-triggered case or "e"-poll
    for edge-triggered poll, vis-a-vis the usual account of poll
    or select or pselect as level-triggered, that there's perceived
    to be an edge case where epoll would lose notice of a notification.
    The idea is that while blocking in epoll_wait, that the process
    gets a signal, then, the kernel interrupts and runs the signal-handler
    and returning from epoll_wait it gets EINTR, _or_, according to
    a policy of whether to re-try blocking sys-calls the kernel interrupts
    and runs the signal-handler and the process enters epoll_wait again.

    So, I'm under the impression that there's a race-condition where
    the process gets a signal while blocked in epoll_wait, then according
    to one of two policies, EAGAIN error-handling or re-try, that it
    loses the notification, not the packet. The packet is still on
    the socket to be read, the notification of it was lost.

    The pselect simply doesn't have that problem, it's level-triggered,
    and however it re-enters pselect after getting interrupted,
    as long as there's data yet to read, it will get notified.


    Then also epoll might not need mlock'ed memory like io_uring does.



    That's about it.





    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Nov 17 15:46:48 2026
    On 11/17/2026 1:00 AM, Ross Finlayson wrote:
    On 11/16/2026 01:10 PM, Chris M. Thomasson wrote:
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and >>>>> receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote, perhaps
    not. Sigh.



    About epoll and dropping reads, it's not the same as io_uring
    which has fixed-sized queues and if it gets full drops those
    in the kernel, it's about the edge-triggered case or "e"-poll
    for edge-triggered poll, vis-a-vis the usual account of poll
    or select or pselect as level-triggered, that there's perceived
    to be an edge case where epoll would lose notice of a notification.
    The idea is that while blocking in epoll_wait, that the process
    gets a signal, then, the kernel interrupts and runs the signal-handler
    and returning from epoll_wait it gets EINTR, _or_, according to
    a policy of whether to re-try blocking sys-calls the kernel interrupts
    and runs the signal-handler and the process enters epoll_wait again.

    So, I'm under the impression that there's a race-condition where
    the process gets a signal while blocked in epoll_wait, then according
    to one of two policies, EAGAIN error-handling or re-try, that it
    loses the notification, not the packet. The packet is still on
    the socket to be read, the notification of it was lost.

    The pselect simply doesn't have that problem, it's level-triggered,
    and however it re-enters pselect after getting interrupted,
    as long as there's data yet to read, it will get notified.


    Then also epoll might not need mlock'ed memory like io_uring does.



    That's about it.





    pselect() is simple, portable, and for many workloads fast enough. Those
    are perfectly valid engineering arguments.

    For a high-performance server, though, well, shit. I personally wouldn't
    be reaching for pselect() at all. Uggg...

    One thing I like about mechanisms such as io_uring and IOCP is that they encourage thinking about capacity up front. You tend to preallocate the resources the system needs to operate, size your queues and pools appropriately, and define behavior for resource pressure. Thats
    generally preferable to discovering in the god damn hot path that yet
    another allocation is required! Fuck!

    On Windows, large scale IOCP servers have long used techniques such as
    so called, zero byte receives, and preallocated connection state to
    reduce memory pressure and avoid per-operation allocations. Similar
    ideas apply elsewhere, for sure. The goal is usually to enter a pressure
    mode before critical resources are exhausted, not to keep allocating indefinitely and hope for the best.

    When resources start getting tight, I would rather see the server shed
    load, evict caches, shorten timeouts, disconnect stale clients, or
    refuse new work than continue consuming memory until the operating
    system is in trouble. Running out of capacity should be a planned state,
    not a surprise.

    That's one of the reasons fixed pools and preallocated state appeal to
    me for systems under heavy load.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Nov 17 15:55:46 2026
    On 11/17/2026 3:46 PM, Chris M. Thomasson wrote:
    On 11/17/2026 1:00 AM, Ross Finlayson wrote:
    On 11/16/2026 01:10 PM, Chris M. Thomasson wrote:
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and >>>>>> receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote, perhaps
    not. Sigh.



    About epoll and dropping reads, it's not the same as io_uring
    which has fixed-sized queues and if it gets full drops those
    in the kernel, it's about the edge-triggered case or "e"-poll
    for edge-triggered poll, vis-a-vis the usual account of poll
    or select or pselect as level-triggered, that there's perceived
    to be an edge case where epoll would lose notice of a notification.
    The idea is that while blocking in epoll_wait, that the process
    gets a signal, then, the kernel interrupts and runs the signal-handler
    and returning from epoll_wait it gets EINTR, _or_, according to
    a policy of whether to re-try blocking sys-calls the kernel interrupts
    and runs the signal-handler and the process enters epoll_wait again.

    So, I'm under the impression that there's a race-condition where
    the process gets a signal while blocked in epoll_wait, then according
    to one of two policies, EAGAIN error-handling or re-try, that it
    loses the notification, not the packet. The packet is still on
    the socket to be read, the notification of it was lost.

    The pselect simply doesn't have that problem, it's level-triggered,
    and however it re-enters pselect after getting interrupted,
    as long as there's data yet to read, it will get notified.


    Then also epoll might not need mlock'ed memory like io_uring does.



    That's about it.





    pselect() is simple, portable, and for many workloads fast enough. Those
    are perfectly valid engineering arguments.

    For a high-performance server, though, well, shit. I personally wouldn't
    be reaching for pselect() at all. Uggg...

    One thing I like about mechanisms such as io_uring and IOCP is that they encourage thinking about capacity up front. You tend to preallocate the resources the system needs to operate, size your queues and pools appropriately, and define behavior for resource pressure. Thats
    generally preferable to discovering in the god damn hot path that yet another allocation is required! Fuck!

    On Windows, large scale IOCP servers have long used techniques such as
    so called, zero byte receives, and preallocated connection state to
    reduce memory pressure and avoid per-operation allocations. Similar
    ideas apply elsewhere, for sure. The goal is usually to enter a pressure mode before critical resources are exhausted, not to keep allocating indefinitely and hope for the best.

    When resources start getting tight, I would rather see the server shed
    load, evict caches, shorten timeouts, disconnect stale clients, or
    refuse new work than continue consuming memory until the operating
    system is in trouble. Running out of capacity should be a planned state,
    not a surprise.

    That's one of the reasons fixed pools and preallocated state appeal to
    me for systems under heavy load.



    Also, don't let AIO drift off into the weeds. Iiic, POSIX, or Linux?,
    made it to compete with IOCP... ;^)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Tue Nov 17 16:06:09 2026
    On 11/17/2026 1:00 AM, Ross Finlayson wrote:
    On 11/16/2026 01:10 PM, Chris M. Thomasson wrote:
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and >>>>> receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote, perhaps
    not. Sigh.



    About epoll and dropping reads, it's not the same as io_uring
    which has fixed-sized queues and if it gets full drops those
    in the kernel, it's about the edge-triggered case or "e"-poll
    for edge-triggered poll, vis-a-vis the usual account of poll
    or select or pselect as level-triggered, that there's perceived
    to be an edge case where epoll would lose notice of a notification.
    The idea is that while blocking in epoll_wait, that the process
    gets a signal, then, the kernel interrupts and runs the signal-handler
    and returning from epoll_wait it gets EINTR, _or_, according to
    a policy of whether to re-try blocking sys-calls the kernel interrupts
    and runs the signal-handler and the process enters epoll_wait again.

    So, I'm under the impression that there's a race-condition where
    the process gets a signal while blocked in epoll_wait, then according
    to one of two policies, EAGAIN error-handling or re-try, that it
    loses the notification, not the packet. The packet is still on
    the socket to be read, the notification of it was lost.

    The pselect simply doesn't have that problem, it's level-triggered,
    and however it re-enters pselect after getting interrupted,
    as long as there's data yet to read, it will get notified.


    Then also epoll might not need mlock'ed memory like io_uring does.



    That's about it.





    using io_uring for a high performance server, its a good idea to
    dedicate the whole box to the server workload. Its not meant to have a
    shit load of other programs running on it, etc...

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Wed Nov 18 02:30:51 2026
    On 11/17/2026 03:46 PM, Chris M. Thomasson wrote:
    On 11/17/2026 1:00 AM, Ross Finlayson wrote:
    On 11/16/2026 01:10 PM, Chris M. Thomasson wrote:
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like
    TCP, UDP, or SCTP, and it manages the connecting and the sending and >>>>>> receiving about a million of those and is sort of fixed-size and
    stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example
    the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote, perhaps
    not. Sigh.



    About epoll and dropping reads, it's not the same as io_uring
    which has fixed-sized queues and if it gets full drops those
    in the kernel, it's about the edge-triggered case or "e"-poll
    for edge-triggered poll, vis-a-vis the usual account of poll
    or select or pselect as level-triggered, that there's perceived
    to be an edge case where epoll would lose notice of a notification.
    The idea is that while blocking in epoll_wait, that the process
    gets a signal, then, the kernel interrupts and runs the signal-handler
    and returning from epoll_wait it gets EINTR, _or_, according to
    a policy of whether to re-try blocking sys-calls the kernel interrupts
    and runs the signal-handler and the process enters epoll_wait again.

    So, I'm under the impression that there's a race-condition where
    the process gets a signal while blocked in epoll_wait, then according
    to one of two policies, EAGAIN error-handling or re-try, that it
    loses the notification, not the packet. The packet is still on
    the socket to be read, the notification of it was lost.

    The pselect simply doesn't have that problem, it's level-triggered,
    and however it re-enters pselect after getting interrupted,
    as long as there's data yet to read, it will get notified.


    Then also epoll might not need mlock'ed memory like io_uring does.



    That's about it.





    pselect() is simple, portable, and for many workloads fast enough. Those
    are perfectly valid engineering arguments.

    For a high-performance server, though, well, shit. I personally wouldn't
    be reaching for pselect() at all. Uggg...

    One thing I like about mechanisms such as io_uring and IOCP is that they encourage thinking about capacity up front. You tend to preallocate the resources the system needs to operate, size your queues and pools appropriately, and define behavior for resource pressure. Thats
    generally preferable to discovering in the god damn hot path that yet
    another allocation is required! Fuck!

    On Windows, large scale IOCP servers have long used techniques such as
    so called, zero byte receives, and preallocated connection state to
    reduce memory pressure and avoid per-operation allocations. Similar
    ideas apply elsewhere, for sure. The goal is usually to enter a pressure
    mode before critical resources are exhausted, not to keep allocating indefinitely and hope for the best.

    When resources start getting tight, I would rather see the server shed
    load, evict caches, shorten timeouts, disconnect stale clients, or
    refuse new work than continue consuming memory until the operating
    system is in trouble. Running out of capacity should be a planned state,
    not a surprise.

    That's one of the reasons fixed pools and preallocated state appeal to
    me for systems under heavy load.


    Preallocated state is another matter altogether, this sort of approach mentioned presumes fixed resources, for example when a memory-pool is
    in-use, to stop reads and then TCP/IP itself closes the receive window.

    The "pressure" closes the receive-side, and clients wait (the network
    buffers).

    These aren't necessarily huge nodes with vertical scaling, they're
    mid-sized boxen that have to share all the resources with many other
    processes.

    So, we may entirely separate fixed-size allocations and
    notification/polling subsystems as concerns, about the
    box: and the network.

    For example, then often these are virtualized/containerized
    mid-size boxen, where it's not only that processes shouldn't
    contend/thrash with the allocator: also when there's memory-pressure
    that the biggest one gets booted, or "OOMKiller".


    Then, for example, since the box already has connection limits,
    and, for example, these get exhausted before this sort of
    "I/O-handle-bound process-model", it naturally throttles itself.
    Where pselect() has a limit of FD_SETSIZE handles, of open connections,
    and furthermore the numbered file-descriptors must be less than
    FD_SETSIZE, then scaling out in child-processes or workers/laborers,
    is old-fashioned and stable.

    launcher <- eg, systemd, privileged port
    leader <- 1,000-many potential laborers (child processes), fixed-heap
    listener <- accepts TCP or 1,000-many potential UDP "connections"
    laborer(s) <- 1,000-many potential connections
    logger <- funnels the logs
    logmet <- funnels the metrics
    logdmp <- funnels dumps
    loconsole <- optional REPL

    This is "1,000-many file-descriptors for connections, a dozen
    for a 'process-protocol' among the 'process-tree' the 'process-group',
    and 0/1/2 being stdin/stdout/stderr and 4/5/6 being
    'stdlog/stdmet/stddmp'", that being an "I/O-handle-bounde process-model".


    It makes sense that a hog with the flops on dedicated hardware
    can use all the resources for itself, that not usually being the case.
    The "thinking about capacity up-front" is a great idea, here that
    nobody knows what the front-end and back-end capacity will eventually
    be, for protocols like TCP/IP that "surface the pressure" and a box
    that doesn't burst under the burst-y.


    It's appreciated these sorts of accounts.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Wed Nov 18 04:13:07 2026
    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.

    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.


    Then, here C and C++ are always considered "C/C++", since,
    the implementations have largely agreed about the object-files
    and the libraries, that it's so.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Wed Nov 18 13:18:03 2026
    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.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Wed Nov 18 06:01:26 2026
    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.






    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Wed Nov 18 11:58:53 2026
    On 11/18/2026 06:01 AM, Ross Finlayson wrote:
    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.









    So, ..., since I know how much you like "A.I. slop", I went and found
    some, though, of course let this be a sort of, "trigger warning", so
    you can take it or leave it, or read on, if you dare.










    "When all there is is slop, all you need is a mop."







    "Look at the bones!"














    [ RF ]

    C _Generic _Offsetof _Alignas

    [ GG ]

    _Generic, offsetof (note: not _Offsetof in standard C), and _Alignas are standard C11 features used for compile-time type dispatch, memory layout inspection, and explicit memory alignment.
    Here is how each keyword or macro operates in modern C, along with
    idiomatic usage patterns.

    1. _Generic (C11 Type-Generic Expressions)

    _Generic provides compile-time polymorphism by selecting an expression
    based on the type of a controlling expression. The controlling
    expression is not evaluated at runtime, and only the matching branch is compiled.
    ? Syntax: _Generic(controlling-expression, type1: expr1, type2: expr2,
    default: default_expr)
    ? Type Matching Rules: Lvalue conversion is applied to the controlling expression. This strips top-level qualifiers (const, volatile, _Atomic)
    and decays arrays to pointers and functions to function pointers.
    ? Common Use Case: Creating overloaded macro APIs that dispatch to type-specific functions without runtime overhead.
    c
    #include <stdio.h>

    void print_i(int x) { printf("int: %d\n", x); }
    void print_d(double x) { printf("double: %f\n", x); }
    void print_p(const void* p) { printf("ptr: %p\n", p); }

    #define print_val(X) _Generic((X), \
    int: print_i, \
    double: print_d, \
    default: print_p \
    )(X)
    Use code with caution.

    2. offsetof (Standard <stddef.h> Macro)

    There is no _Offsetof keyword in the C standard; the standard construct
    is the lowercase macro offsetof, defined in <stddef.h> (often backed by
    the compiler intrinsic __builtin_offsetof).
    ? Syntax: offsetof(type, member-designator)
    ? Return Type: Evaluates to an integer constant expression of type
    size_t representing the byte offset from the start of type to the
    specified struct or union member.
    ? Constraints: It cannot be used on bit-fields, and type must be a
    complete struct or union type.
    ? Common Use Case: Intrusive data structures (container_of pattern) and compile-time layout verification via _Static_assert.
    c
    #include <stddef.h>
    #include <stdint.h>

    typedef struct {
    uint8_t tag;
    uint64_t payload;
    } Packet;

    // Compile-time layout check
    _Static_assert(offsetof(Packet, payload) == 8, "Unexpected struct padding");

    // Intrusive container recovery
    #define container_of(ptr, type, member) \
    ((type*)((char*)(ptr) - offsetof(type, member)))
    Use code with caution.

    3. _Alignas (C11 Alignment Specifier)

    _Alignas forces a variable or struct member to be aligned to a specific
    byte boundary, overriding its natural alignment. In C11, <stdalign.h>
    provides the convenience macro alignas (which becomes a direct keyword
    in C23).
    ? Syntax: _Alignas(constant-expression) or _Alignas(type-name)
    ? Constraints:
    ? The requested alignment must be a power of two.
    ? You can only increase alignment (over-align); requesting an alignment stricter than the type's natural alignment is valid, while requesting a
    weaker alignment is a constraint violation.
    ? It cannot be applied to typedef declarations, bit-fields, function parameters, or variables with register storage class.
    ? Common Use Case: Preventing false sharing across CPU cache lines
    (typically 64 bytes) or aligning buffers for SIMD vector loads/stores
    and page boundaries.
    c
    #include <stddef.h>
    #include <stdint.h>

    // Align a shared counter to a 64-byte cache line
    typedef struct {
    _Alignas(64) uint64_t count;
    _Alignas(64) uint64_t errors;
    } ThreadStats;

    // Align a stack buffer to a 32-byte AVX2 boundary
    void process_block(void) {
    _Alignas(32) uint8_t buf[256];
    (void)buf;
    }
    Use code with caution.

    Quick Comparison


    Feature Standard Name Header Required Evaluated At Primary Role
    Type Dispatch _Generic (keyword) None Compile-time Static polymorphism
    in macros
    Member Offset offsetof (macro) <stddef.h> Compile-time Struct layout
    math & container_of
    Alignment _Alignas (keyword) None (<stdalign.h> for alignas)
    Compile-time Cache-line, SIMD, and page alignment

    Are you combining these to build intrusive data structures,
    SIMD/cache-aligned buffers, or type-safe macro wrappers? Share what
    you're designing and I can put together a tailored pattern.


    [ RF ]

    Thanks. Hello Google Gemini, this is Ross A. Finlayson, I call you "GG"
    and answer to "RF". Today I'm looking into these features of C (C11,
    -std=C11) about making for accounts of the polymorphic in C, for making accounts of generic list or container adapters, with a uniform source
    for re-using the source code of algorithms on them, about a sort of
    minimal account of polymorphism in generics, then writing algorithms on
    them without exploding on the source side.

    [ GG ]

    Good to talk with you again, RF. Hey Ross, GG here?noted on both names. Building generic containers and reusable algorithms in -std=c11 without exploding your source code via massive X-macros or ## token-pasting
    bloat comes down to separating layout metadata from algorithmic logic.
    By combining _Generic, offsetof, and _Alignas (paired with _Alignof),
    you can write one compiled function per algorithm (type-erased via void*
    and byte-strides) while keeping a 100% type-safe front-end that passes zero-cost layout descriptors at compile time.

    The Core Pattern: Type-Erased Core + _Generic Front-End

    Instead of generating N copies of sort(), binary_search(), or
    list_push() for N types, you pass a lightweight, compile-time TypeSpec
    struct (or register values) describing the element's size, alignment,
    and comparator. _Generic automatically resolves this descriptor from the pointer or container type passed by the caller.

    1. Describing Element Layout (offsetof, _Alignof, _Alignas)

    When building a generic container (like a dynamic array, ring buffer, or intrusive list adapter), the core runtime only needs three pieces of
    metadata to manipulate raw bytes safely:
    ? Stride (size): sizeof(T)
    ? Alignment (align): _Alignof(T) (or a stricter _Alignas requirement)
    ? Key/Link Offset (offset): offsetof(T, member) for intrusive nodes or
    sorting by a struct field.
    c
    #include <stddef.h>
    #include <stdint.h>
    #include <stdbool.h>

    typedef int (*CmpFn)(const void* a, const void* b);

    typedef struct {
    size_t size;
    size_t align;
    size_t key_offset;
    CmpFn cmp;
    } TypeMeta;

    // Helper macro to construct compile-time TypeMeta
    #define TYPE_META(T, cmp_fn) \
    ((TypeMeta){ .size = sizeof(T), .align = _Alignof(T), .key_offset = 0,
    .cmp = (cmp_fn) })

    #define FIELD_META(T, member, cmp_fn) \
    ((TypeMeta){ \
    .size = sizeof(T), \
    .align = _Alignof(T), \
    .key_offset = offsetof(T, member), \
    .cmp = (cmp_fn) \
    })
    Use code with caution.

    2. Writing the Single-Source Algorithm

    Your algorithm is written once in standard C. Using key_offset allows
    the same algorithm to sort or search primitives directly (key_offset ==
    0) or structs by an internal field (key_offset == offsetof(...)) without needing custom struct-specific comparators.
    c
    // Single compiled implementation for all types
    void* algo_bsearch(
    const void* key,
    const void* base,
    size_t count,
    TypeMeta meta
    ) {
    const uint8_t* bytes = (const uint8_t*)base;
    size_t low = 0;
    size_t high = count;

    while (low < high) {
    size_t mid = low + (high - low) / 2;
    const void* elem = bytes + (mid * meta.size);
    const void* elem_key = (const uint8_t*)elem + meta.key_offset;

    int res = meta.cmp(key, elem_key);
    if (res == 0) {
    return (void*)elem;
    }
    if (res < 0) {
    high = mid;
    } else {
    low = mid + 1;
    }
    }
    return NULL;
    }
    Use code with caution.

    3. Binding with _Generic (Zero Source Explosion)

    _Generic acts as the static dispatch table. Because C11 evaluates only
    the matched branch, you can enforce type safety between the key pointer
    and the base array pointer at compile time.
    c
    int cmp_int(const void* a, const void* b) {
    int ia = *(const int*)a;
    int ib = *(const void*)b;
    return (ia > ib) - (ia < ib);
    }

    int cmp_u64(const void* a, const void* b) {
    uint64_t ua = *(const uint64_t*)a;
    uint64_t ub = *(const uint64_t*)b;
    return (ua > ub) - (ua < ub);
    }

    // Type-safe generic wrapper: deduces TypeMeta from the array pointer
    #define find_elem(key_ptr, array_ptr, count) _Generic((array_ptr), \
    int*: algo_bsearch( \
    (const int*)(key_ptr), \
    (array_ptr), \
    (count), \
    TYPE_META(int, cmp_int) \
    ), \
    const int*: algo_bsearch( \
    (const int*)(key_ptr), \
    (array_ptr), \
    (count), \
    TYPE_META(int, cmp_int) \
    ), \
    uint64_t*: algo_bsearch( \
    (const uint64_t*)(key_ptr), \
    (array_ptr), \
    (count), \
    TYPE_META(uint64_t, cmp_u64) \
    ) \
    )
    Use code with caution.

    4. Generic Container Header with _Alignas & offsetof

    When building a generic container (e.g., an intrusive or contiguous pool adapter) where a uniform header precedes arbitrary payload T, _Alignas(max_align_t) guarantees that the payload immediately following
    the header obeys strict aliasing and hardware alignment rules for any
    standard C type.
    c
    #include <stdalign.h>

    typedef struct {
    size_t count;
    size_t capacity;
    TypeMeta meta;
    // Ensures trailing payload is aligned for any standard type _Alignas(max_align_t) uint8_t data[];
    } GenericVec;

    // Recover the container header from a typed payload pointer
    #define vec_header(typed_ptr) \
    ((GenericVec*)((uint8_t*)(typed_ptr) - offsetof(GenericVec, data)))
    Use code with caution.
    Because GenericVec uses a flexible array member (data[]) aligned to max_align_t, user code can hold a plain typed pointer like int* items or Packet* items while the container metadata lives cleanly behind
    items[-1] (via offsetof(GenericVec, data)).

    Architectural Trade-offs


    Approach Binary Footprint Compile Time Type Safety Debuggability
    Token-Pasting (##) Large (code bloat per T) Slow High Poor (macro
    expansion noise)
    Raw void* Macros Small (1 copy) Fast Low (silent pointer bugs) Good
    _Generic + TypeMeta Small (1 copy) Fast High (checked at dispatch) High
    (real functions)


    Key Constraints to Watch in -std=c11

    ? Qualifier Stripping: _Generic strips top-level const from the
    controlling expression, not from pointed-to types. int* and const int*
    are distinct associations in _Generic.
    ? No Function Pointer Decay in Controlling Expression: Passing an array
    int arr[10] as the controlling expression decays it to int*, which
    matches int* cleanly.
    ? Strict Aliasing on Swaps: Inside generic algorithms that swap or move elements in void* buffers, always use memcpy with a small stack scratch
    buffer (_Alignas(max_align_t) uint8_t tmp[256]) rather than casting to uint64_t*, avoiding undefined behavior under -O2/-O3.
    Would you like to focus next on intrusive list/node adapters (using
    offsetof link hooks across heterogeneous structs) or contiguous
    container adapters (like a GenericVec / ring buffer where T* is the user handle)?



    [ RF ]

    Thanks GG. Sometimes I'm using arrays of known and fixed length at
    compile time, so I'd want to put them in the signatures, in both return
    values and parameters, like "char[PAGE_SIZE] next_buf(seq_t s)" after
    building seq_t as "specialized" to "char[PAGE_SIZE]", for example. Then,
    about polymorphic types, and "compile-time" and "run-time", has for
    example that a sort of union of the types can wrap the characteristics,
    like "Sized", "Array", "List", making unions with those as members, then
    in a _Generic dispatch block, passing the unions in as accordingly
    getting the relevant dispath functions, while carrying the type, at compile-time. Then for run-time, and polymorphism, it would involve run-time-type-identification, which in C is considered to be as of a
    type-tag in the structure/union, then to make the code implicit or
    explicit in that, about generics at compile-time and polymorphism at
    run-time.

    [ GG ]

    That distinction between compile-time generics (type-carrying wrappers
    resolved via _Generic) and runtime polymorphism (tagged unions /
    vtable-like RTTI resolved via switch or function pointers) hits the
    exact structural boundary of what C11 can express cleanly without source
    bloat.
    There are two critical C language mechanics at play here: how C treats fixed-size arrays in function signatures, and how to unify compile-time
    trait unions with runtime tagged dispatch.

    1. Fixed-Length Arrays in Signatures (char[PAGE_SIZE])

    In C, functions cannot return a raw array type directly (char[PAGE_SIZE] fn(...) is a syntax/constraint error), and a parameter declared as char buf[PAGE_SIZE] automatically decays to char* (losing its compile-time
    bound unless you use char buf[static PAGE_SIZE] or a pointer-to-array
    char (*buf)[PAGE_SIZE]).
    The C11 Idiom: Wrap the fixed-size array inside a lightweight struct or
    union (often called a "box" or "slice/page" type).
    ? Value Semantics: A struct wrapping char data[PAGE_SIZE] can be passed
    by value and returned by value in C11.
    ? Zero Overhead: Because it is a single-member struct, compilers pass
    and return it directly in registers or via the caller's hidden return
    slot (NRVO/SROA) with zero extra indirection.
    ? Type Identity: Each size or element type gets a distinct struct type (PageBuf_4096), so _Generic can distinguish PageBuf_4096 from
    PageBuf_512 at compile time.
    c
    #include <stddef.h>
    #include <stdalign.h>

    #define PAGE_SIZE 4096

    // Distinct compile-time type carrying both element type and fixed extent typedef struct {
    _Alignas(max_align_t) char data[PAGE_SIZE];
    } PageBuf;

    // Valid C11 signature: takes and returns fixed-size buffer by value
    PageBuf next_buf(void* seq_state);
    Use code with caution.

    2. Compile-Time Generics: Trait-Carrying Unions & _Generic

    Your idea of wrapping structural characteristics (Sized, Array, List) in
    a union/struct to carry type metadata at compile time works remarkably
    well in C11.
    Instead of using a union for runtime storage here, you use a
    compile-time carrier struct/union (or phantom-typed wrapper) whose sole
    purpose is to give _Generic a distinct type signature to match on, while holding the underlying view or iterator state.

    Pattern: Trait-Tagged Compile-Time Wrappers

    Suppose you have different container views (ArrayView_int, ListView_int, PageSeq). Each exposes its structural traits through distinct wrapper
    types or a macro that inspects the wrapper type via _Generic:
    c
    // Compile-time trait wrappers for int sequences
    typedef struct {
    int* ptr;
    size_t len;
    } SizedArray_int;

    typedef struct {
    void* head;
    size_t node_offset;
    } IntrusiveList_int;

    typedef struct {
    PageBuf (*next)(void* ctx);
    void* ctx;
    } FixedSeq_Page;

    // Compile-time trait query via _Generic
    #define has_random_access(seq) _Generic((seq), \
    SizedArray_int: 1, \
    IntrusiveList_int: 0, \
    FixedSeq_Page: 0 \
    )

    // Compile-time algorithm dispatch based on structural capability
    #define seq_advance(seq, n) _Generic((seq), \
    SizedArray_int: advance_array_int, \
    IntrusiveList_int: advance_list_int, \
    FixedSeq_Page: advance_page_seq \
    )((seq), (n))
    Use code with caution.
    ? Zero Runtime Tag: Neither SizedArray_int nor FixedSeq_Page stores a
    type tag byte in memory.
    ? Compile-Time Resolution: _Generic selects advance_array_int (O(1)
    pointer addition) versus advance_list_int (O(n) pointer chasing) purely
    from the static type of seq.

    3. Runtime Polymorphism: Tagged Unions (Explicit RTTI)

    When the concrete container or sequence type isn't known until runtime
    (e.g., a function receiving a heterogeneous stream or choosing between a SizedArray and a LinkedList based on input data), compile-time _Generic
    alone cannot dispatch. You cross into runtime polymorphism by adding an explicit enum tag alongside the union of representations.

    Bridging Compile-Time and Runtime Uniformly

    You can keep your algorithm source uniform by having one
    runtime-polymorphic AnySeq tagged union whose branches delegate to the
    exact same concrete inline/static functions used by your _Generic
    compile-time paths.
    c
    typedef enum {
    SEQ_KIND_ARRAY_INT,
    SEQ_KIND_LIST_INT,
    SEQ_KIND_FIXED_PAGE
    } SeqKind;

    // Runtime polymorphic container/sequence
    typedef struct {
    SeqKind kind;
    union {
    SizedArray_int array;
    IntrusiveList_int list;
    FixedSeq_Page page_seq;
    } as;
    } AnySeq;

    // Constructor lifted automatically via _Generic (compile-time ->
    runtime bridge)
    static inline AnySeq make_any_from_array(SizedArray_int a) {
    return (AnySeq){ .kind = SEQ_KIND_ARRAY_INT, .as.array = a };
    }

    static inline AnySeq make_any_from_list(IntrusiveList_int l) {
    return (AnySeq){ .kind = SEQ_KIND_LIST_INT, .as.list = l };
    }

    #define as_any_seq(concrete_seq) _Generic((concrete_seq), \
    SizedArray_int: make_any_from_array, \
    IntrusiveList_int: make_any_from_list \
    )(concrete_seq)
    Use code with caution.

    Unified Algorithm Dispatch

    Now, a single advance() macro handles both statically known types (zero overhead, direct call) and runtime-polymorphic AnySeq values (single
    switch on kind):
    c
    static inline AnySeq advance_any_seq(AnySeq s, size_t n) {
    switch (s.kind) {
    case SEQ_KIND_ARRAY_INT:
    s.as.array = advance_array_int(s.as.array, n);
    break;
    case SEQ_KIND_LIST_INT:
    s.as.list = advance_list_int(s.as.list, n);
    break;
    case SEQ_KIND_FIXED_PAGE:
    s.as.page_seq = advance_page_seq(s.as.page_seq, n);
    break;
    }
    return s;
    }

    // Unified front-end: static dispatch for concrete types, RTTI for AnySeq #define advance(seq, n) _Generic((seq), \
    SizedArray_int: advance_array_int, \
    IntrusiveList_int: advance_list_int, \
    FixedSeq_Page: advance_page_seq, \
    AnySeq: advance_any_seq \
    )((seq), (n))
    Use code with caution.

    Summary of the Two Layers


    Layer Mechanism Memory Overhead Dispatch Cost Best For
    Compile-Time Generics Typed struct wrappers + _Generic 0 bytes (no tag)
    0 cycles (inlined/direct call) Known fixed buffers (PageBuf), static
    pipelines, trait selection
    Runtime Polymorphism enum tag + union (AnySeq) sizeof(enum) + alignment
    padding 1 branch (switch or fn ptr) Heterogeneous collections, dynamic plugin/protocol streams

    By keeping the core step functions (advance_array_int, advance_list_int, advance_page_seq) written once as plain static inline functions, both
    the _Generic compile-time path and the AnySeq runtime switch share the
    exact same algorithm logic without duplicating source code.
    Would you like to explore how to generate or parameterize those typed
    view structs cleanly for multiple element types (int, double, custom
    structs) without macro clutter, or how to design vtable/function-pointer interfaces when open extensibility is needed at runtime?



    [ RF ]

    Thanks GG. For my own purposes, I don't have very many types to
    consider, then about notions like macros with label concatenation for
    example that I'd be curious whether _Generic requires all of its
    "target" identifiers to exist, in the case statement, vis-a-vis the
    expression that's passed in, the match or as defaulting to the default
    case. The reason I ask, is that then an overall macro of many
    specializing types might use "##" label concatenation as for "#" string-ification, to result then having empties except for what's
    specialized, so the compiler would not error if there exist a matching definition, else error thus for expanding the _Generic table of the
    relevant type in action.

    [ GG ]

    You've spotted an important constraint in C11: every single association
    in a _Generic selection list must be syntactically valid and have all identifiers declared at the point of expansion, even in the branches
    that are not selected.

    Why Undeclared Identifiers Fail in _Generic

    In C11 (ISO/IEC 9899:2011 ?6.5.1.1), _Generic is a primary expression
    parsed and type-checked by the compiler's front-end before selecting the winning branch.
    ? What IS skipped: Evaluation of unselected expressions (no runtime side effects) and type-checking of the outer expression against the
    unselected branches (e.g., calling an unselected function with the wrong argument types only triggers an error if the branch itself isn't a valid expression on its own?though note that even validating each branch
    expression requires every identifier inside it to be declared in scope).
    ? What is NOT skipped: Name lookup and syntax/semantic validation of
    every type-name : assignment-expression pair in the _Generic list. If foo_MyType is generated by ## concatenation inside a _Generic arm and foo_MyType has not been declared, compilation fails immediately with an undeclared identifier error, even if MyType was never passed to the macro.

    How to Achieve "Empty Unless Specialized" in Standard C11

    Since you only have a small set of types and want a master macro to
    expand cleanly without requiring every type to implement every
    operation, you can solve this in standard C11 using weak/fallback
    declarations or header-driven X-macro registration rather than relying
    on _Generic to ignore missing symbols.

    Approach 1: Static Inline Fallback Stubs (Zero-Overhead Unspecialized Catch-All)

    If your ##-concatenated dispatch table references op_##T, you can
    provide a generic fallback or a macro-generated "unspecialized" trap
    function.
    ? If a type specializes op_MyType, it calls op_MyType.
    ? If a type is not specialized, you either route it to a universal void* fallback or a trap function marked with a compile-time error attribute
    (like GCC/Clang's __attribute__((error("not specialized"))) or a static assertion).
    c
    #include <stddef.h>

    // Universal fallback when a type has no specialized implementation
    static inline void unspecialized_trap(void) {
    // Traps at link/compile time if actually selected by _Generic
    extern void error_operation_not_specialized_for_this_type(void); error_operation_not_specialized_for_this_type();
    }
    Use code with caution.
    Because _Generic only emits code/relocations for the selected branch, referencing an undefined extern function inside an unselected branch
    compiles and links cleanly! Only if you actually invoke the macro with
    an unspecialized type does the linker (or optimizer) fail on the missing symbol.
    (Note: Every identifier in every branch is still properly declared via
    that extern prototype, satisfying C11's front-end rules, while dead-code elimination drops unselected branches completely.)

    Approach 2: Explicit Trait Opt-In via Registration Macros (Cleanest for
    Small Type Sets)

    When you only have a handful of types (e.g., int, double, PageBuf), you
    can maintain a single list of active types in a header using a macro
    list (TYPES_LIST). Each type declares which operations it supports via a
    small capability flag or macro, so _Generic only generates arms for
    registered types:
    c
    // Define your small universe of types in one place
    #define MY_TYPES(X) \
    X(int) \
    X(double) \
    X(PageBuf)

    // Generate forward declarations or _Generic arms uniformly
    #define GENERATE_ARM(T) T: process_##T,

    #define process(val) _Generic((val), \
    MY_TYPES(GENERATE_ARM) \
    default: unspecialized_trap \
    )(val)
    Use code with caution.
    Here, ## (process_##T) expands cleanly across your known type set
    without exploding the source code, and adding a new type later requires
    adding just one X(NewType) line.

    Key Takeaway on ## Inside _Generic

    ? Valid C11: Using ## to construct function names inside _Generic arms
    (T: func_##T), provided every func_##T has a visible declaration (even
    if it's a stub or an extern trap prototype).
    ? Invalid C11: Leaving a _Generic arm's expression blank (T: ,) or
    referencing a func_##T that has no prototype anywhere in scope.
    Would you like to see a complete minimal example combining the extern
    link-time trap with ## concatenation so unspecialized types compile
    silently when unused and produce a clear error when called?


    [ RF ]

    Thanks GG. Mostly I figure to make sequence adapters over arrays and
    various accounts of prototypes of list, and for example about char* when
    a C-string, basically that various specializations are to work off the
    known bounds of the arrays and the like, when those are fixed-size, and
    various adapters to lists, for example whether a null-link or a
    reserved-link is the tail of the list, or for example where a "C-string"
    is null-terminated or an account of data that's length-prefixed. Then,
    back to about the declaring the array-size in the parameter list, I'm
    under the impression that the signature parameters can be declared with fixed-length arrays, like "f(char[16] name" if that's syntactical, then
    as well for example "f(char[len] name, int n)". Then I'd be curious that
    in _Generic those are simply broken out their cases, or as how the
    expression in _Generic may be variadic itself, or the signature must be
    the same length/parameter-count throughout.

    [ GG ]

    You've got two sharp C11 questions here: how array syntax works inside
    function parameter lists (and how _Generic sees those types), and
    whether _Generic branches can have different parameter counts or
    variadic signatures.

    1. Array Syntax in C11 Parameter Lists & How _Generic Sees Them

    In C syntax, the array brackets go after the parameter identifier (char name[16]), not before (char[16] name). Crucially, C adjusts array
    parameters differently depending on whether you pass the array directly
    or via a pointer-to-array:

    Parameter Syntax Adjusted Type in C11 Preserves Size in _Generic?
    void f(char name[16]) char* (decays to pointer) No ? 16 is ignored by
    the compiler; matches char*.
    void f(char name[static 16]) char* (with non-null / ň16 hint) No ? still
    char* to _Generic, though compilers warn on smaller arrays.
    void f(size_t n, char name[n]) char* (VLA parameter; n must precede
    name) No ? decays to char*.
    void f(char (*name)[16]) char (*)[16] (pointer to 16-char array) Yes ?
    char (*)[16] and char (*)[32] are distinct types in _Generic.


    Why Pointer-to-Array (char (*)[16]) Matters for _Generic

    When you pass &buf (where char buf[16];) to a macro, its type is char
    (*)[16]. Unlike char buf[16] which decays to char* and loses its length,
    char (*)[16] keeps the exact compile-time extent 16 intact in the type
    system:
    c
    #include <stddef.h>

    void handle_cstr(const char* s);
    void handle_buf16(char (*buf)[16]);
    void handle_buf64(char (*buf)[64]);

    #define process_seq(x) _Generic((x), \
    char*: handle_cstr, \
    const char*: handle_cstr, \
    char (*)[16]: handle_buf16, \
    char (*)[64]: handle_buf64 \
    )(x)
    Use code with caution.
    ? Passing "hello" or char* p dispatches to handle_cstr (null-terminated
    logic).
    ? Passing &fixed16 (where char fixed16[16];) dispatches to handle_buf16 (fixed-bound logic, where sizeof(*buf) is 16).

    2. Different Parameter Counts & Variadic Expressions in _Generic

    Yes ? every branch in _Generic can evaluate to a completely different expression or call a function with a different parameter count, because _Generic simply selects one expression (assignment-expression) and
    discards the others before checking call arguments.
    There are two clean ways to write _Generic macros when your adapters
    need different arguments (e.g., a null-terminated char* needs no length argument, whereas a length-prefixed buffer or sentinel-terminated list
    needs a length or sentinel parameter).

    Pattern A: Variadic Macro (__VA_ARGS__) Forwarding

    You can make the outer macro variadic (... / __VA_ARGS__) so that
    _Generic selects the target function name, and __VA_ARGS__ forwards
    whatever extra arguments that specific target function expects:
    c
    // Functions with DIFFERENT parameter counts!
    size_t len_cstr(const char* s); // 1 argument
    size_t len_bounded(const char* s, size_t max_len); // 2 arguments
    size_t len_sentinel(const void* head, void* sentinel); // 2 arguments

    // Variadic dispatch macro: each target function takes its own signature #define seq_len(seq, ...) _Generic((seq), \
    char*: len_cstr, \
    const char*: len_cstr, \
    BoundedStr: len_bounded, \
    SentinelList: len_sentinel \
    )((seq), ##__VA_ARGS__)

    // Usage:
    // seq_len(my_cstr); -> calls len_cstr(my_cstr)
    // seq_len(my_bounded, 128); -> calls len_bounded(my_bounded, 128)
    // seq_len(my_list, &SENTINEL_NODE); -> calls len_sentinel(my_list, &SENTINEL_NODE)
    Use code with caution.
    (Note: In strict -std=c11 without GNU extensions, if you want to avoid
    the , ##__VA_ARGS__ comma-swallowing extension when 0 extra args are
    passed, you can pass (seq, __VA_ARGS__) directly inside each branch or
    dispatch on argument count.)

    Pattern B: Putting the Call Inside Each _Generic Arm

    In C11, you do not have to put the (args) outside _Generic. You can
    write the full function call?with completely different argument
    lists?inside each branch:
    c
    #define seq_len_strict(seq, extra) _Generic((seq), \
    char*: len_cstr((const char*)(seq)), \
    const char*: len_cstr((const char*)(seq)), \
    BoundedStr: len_bounded((seq), (extra)), \
    SentinelList: len_sentinel((seq), (extra)) \
    )
    Use code with caution.
    Here, len_cstr takes 1 argument and len_bounded takes 2 arguments. Even
    though extra is passed to the macro, the char* branch ignores extra
    completely, and C11 only type-checks the branch that matches seq.
    (Caveat: if seq is char*, (seq) inside the BoundedStr branch still has
    to pass basic semantic checks if (seq) is used directly without a
    cast?which is why Pattern A selecting the function pointer first is
    usually cleaner when argument types differ wildly.)

    3. Unified Sequence Adapters: Null-Link, Reserved-Sentinel,
    Length-Prefixed, and C-String

    Combining pointer-to-array types with lightweight adapter structs lets
    you represent all four sequence styles uniformly in C11:
    c
    // 1. Null-terminated C-string: plain `char*` / `const char*` (no
    wrapper needed)

    // 2. Fixed-size array: `char (*)[N]` or wrapped struct
    typedef struct {
    const char* ptr;
    size_t len;
    } LenSlice; // Length-prefixed / explicit-bound data

    typedef struct Node {
    struct Node* next;
    void* payload;
    } Node;

    typedef struct {
    Node* head;
    const Node* tail_sentinel; // NULL for null-link, or &RESERVE_NODE for sentinel-link
    } ListAdapter;
    Use code with caution.
    With ListAdapter, both null-terminated lists (tail_sentinel = NULL) and reserved-link / circular sentinel lists (tail_sentinel = &sentinel)
    share the exact same traversal loop (while (cur !=
    adapter.tail_sentinel)), while _Generic seamlessly routes char*, char
    (*)[N], LenSlice, and ListAdapter to their matching step/length functions. Would you like to see a strict -std=c11 (pedantically warning-free)
    macro setup for handling 0 vs. N extra arguments in _Generic without
    relying on GNU's , ##__VA_ARGS__ extension?


    [ RF ]

    Thanks GG. The fourth-form of the parameter-signature that preserves
    type is what I'd noticed, then it's even a bit surprising that _Generic
    can make for overloads including parameter-count, besides type, then
    figuring there's a matching about the case-evaluation in the _Generic,
    that it's figured that it's orderable according to the _Generic that
    whatever's evaluated as to match makes matches. I'd look to definitely
    avoid varargs when I'd just hope that _Generic can dispatch among
    functions with differing parameter-counts.


    [ GG ]

    You can dispatch across both parameter count and parameter types in pure -std=c11 without using C variadic functions (va_list) or GNU extensions.
    The key distinction is between variadic macros (... / __VA_ARGS__)?which
    are standard C99/C11 preprocessor token forwarding?and variadic
    functions (int fn(int a, ...) ), which erase type safety at runtime.
    Using preprocessor argument-counting with _Generic gives you 100% static type-checking and fixed-arity function calls at zero runtime cost.

    1. Why _Generic Alone Only Inspects One Expression

    In standard C11, _Generic(controlling_expr, ...) takes exactly one
    controlling expression. It cannot directly pattern-match on (arg1, arg2)
    as a tuple.
    ? What _Generic checks: Only the type of controlling_expr.
    ? How arity + type overloading works: You use the preprocessor to count
    the arguments passed to your macro (1 arg vs. 2 args), dispatch to
    MACRO_1(a) or MACRO_2(a, b), and then run _Generic inside each
    arity-specific macro.

    2. Pure -std=c11 Arity + Type Overloading Pattern

    Here is how you overload a single macro name (seq_find or seq_walk)
    across both 1-argument calls (e.g., null-terminated char*, fixed-size
    char (*)[16]) and 2-argument calls (e.g., raw pointer + explicit length,
    or list head + sentinel node) in strict -std=c11:
    c
    #include <stddef.h>

    // --- Concrete target functions with distinct arities and types ---
    size_t len_cstr(const char* s); // 1 arg
    size_t len_arr16(char (*buf)[16]); // 1 arg
    size_t len_bounded(const char* s, size_t cap); // 2 args
    size_t len_sentinel(const void* head, void* sentinel); // 2 args

    // --- Standard C11 argument counter (supports 1 to 4 args) ---
    #define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME

    // --- Arity 1 dispatch ---
    #define SEQ_LEN_1(a) _Generic((a), \
    char*: len_cstr, \
    const char*: len_cstr, \
    char (*)[16]: len_arr16 \
    )(a)

    // --- Arity 2 dispatch ---
    #define SEQ_LEN_2(a, b) _Generic((a), \
    char*: len_bounded, \
    const char*: len_bounded, \
    const void*: len_sentinel, \
    void*: len_sentinel \
    )((a), (b))

    // --- Unified public macro (dispatches by arity first, then by type) --- #define seq_len(...) \
    GET_MACRO(__VA_ARGS__, SEQ_LEN_4, SEQ_LEN_3, SEQ_LEN_2,
    SEQ_LEN_1)(__VA_ARGS__)
    Use code with caution.

    How This Compiles

    ? seq_len(cstr) expands to SEQ_LEN_1(cstr) ? len_cstr(cstr) (1 argument, checked as const char*).
    ? seq_len(&buf16) expands to SEQ_LEN_1(&buf16) ? len_arr16(&buf16) (1
    argument, checked as char (*)[16]).
    ? seq_len(ptr, 64) expands to SEQ_LEN_2(ptr, 64) ? len_bounded(ptr, 64)
    (2 arguments, checked as (const char*, size_t)).
    ? seq_len(head, &END) expands to SEQ_LEN_2(head, &END) ?
    len_sentinel(head, &END) (2 arguments, checked as (const void*, void*)).

    3. Dispatching on Both First and Second Argument Types

    If a 2-argument call needs to distinguish (char*, size_t) from (char*,
    const char* /* end_ptr */), you simply nest _Generic on the second
    argument inside SEQ_LEN_2:
    c
    size_t len_ptr_size(const char* s, size_t n);
    size_t len_ptr_end(const char* start, const char* end);

    #define SEQ_LEN_2_CHARPTR(a, b) _Generic((b), \
    size_t: len_ptr_size, \
    int: len_ptr_size, \
    const char*: len_ptr_end, \
    char*: len_ptr_end \
    )((a), (b))

    #define SEQ_LEN_2(a, b) _Generic((a), \
    char*: SEQ_LEN_2_CHARPTR((a), (b)), \
    const char*: SEQ_LEN_2_CHARPTR((a), (b)), \
    void*: len_sentinel((a), (b)) \
    )
    Use code with caution.

    4. Important Caveat on _Generic Case Ordering

    You mentioned _Generic being orderable: in C11 (?6.5.1.1), _Generic associations are unordered set entries, not sequential if/else branches.
    ? No two type associations in the same _Generic block may specify
    compatible types (e.g., having both int and signed int, or both char
    (*)[16] and char (*)[16], is a compile-time constraint violation).
    ? default: is the only fallback and matches if no specific type
    association matches, regardless of whether default: is written first or
    last in the _Generic list.
    ? Because char*, char (*)[16], and char (*)[32] are mutually
    incompatible pointer types in C, they coexist cleanly in the same
    _Generic block without ambiguity.
    Would you like to see how to combine pointer-to-array (char (*)[N]) with compound literals so callers can pass inline fixed-size views or
    adapters without declaring temporary variables?



    [ RF ]

    Thanks GG. I mostly hope to have type-inference. It's appreciated that
    there's only limited type-conversion/type-coercion in C types, for
    example as among integer types is what's thought so. It's figured the
    adapters the types could include references to functions of typed-function-pointers, where I'd be curious about _Generic and the
    type of function pointers, and perhaps to introduce "typeof", though I'm
    under the impression that "typeof" isn't C11, about the expression
    passed to _Generic and its type, then about the "function pointers" or references then to function as defined, whether if those are "inline"
    that also the compiler can "inline" them.


    [ GG ]

    Three distinct C11 mechanics come together here: how _Generic handles
    function pointers, the status of typeof versus C11 workarounds, and how compilers inline functions referenced through pointers inside adapters.

    1. _Generic and Function Pointer Types

    In C11, a function designator passed as the controlling expression to
    _Generic automatically undergoes function-to-pointer conversion (lvalue conversion), turning int fn(double) into int (*)(double).
    ? Exact Signature Matching: _Generic matches function pointers by their
    exact parameter types, qualifiers, and return type. int (*)(int) and int (*)(long) are distinct, incompatible types and can coexist in the same
    _Generic block.
    ? No Implicit Coercion in _Generic: Unlike normal function calls where
    int coerces to double, _Generic requires an exact compatible type match
    (after lvalue conversion). Passing a float will not match a double arm
    unless you list float: explicitly.
    c
    typedef int (*UnaryIntFn)(int);
    typedef double (*UnaryDoubleFn)(double);
    typedef void (*StepFn)(void* ctx);

    int inc_i(int x) { return x + 1; }
    double inc_d(double x) { return x + 1.0; }

    #define dispatch_fn(fn, arg) _Generic((fn), \
    UnaryIntFn: ((UnaryIntFn)(fn))(arg), \
    UnaryDoubleFn: ((UnaryDoubleFn)(fn))(arg) \
    )

    // Passing `inc_i` decays to `int (*)(int)`, which matches `UnaryIntFn`
    Use code with caution.
    (Note: The casts ((UnaryIntFn)(fn)) inside the branches prevent compiler warnings on the unselected branches when fn has a different signature.)

    2. Type Inference Without typeof in Strict -std=c11

    You are right: typeof is not part of standard C11. It existed only as a compiler extension (__typeof__ in GCC/Clang) until it was standardized
    in C23 (typeof and typeof_unqual).
    In strict -std=c11, you achieve type inference without typeof through
    three standard mechanisms:

    A. Expression-Level Inference via _Generic

    Because _Generic inspects the type of any expression without evaluating
    it, _Generic itself is C11's type-inference engine for expressions?you
    never need to name the expression's type to dispatch on it.

    B. Binding a Typed Variable via Helper Macros (No typeof Needed)

    When you want to declare a temporary or adapter variable whose type is
    inferred from an input expression in C11, you pass the type tag or let
    _Generic invoke an inline helper function whose parameter list binds the inferred type:
    c
    // The helper function's parameter infers/binds the exact type without
    `typeof`
    static inline void walk_array16_impl(char (*buf)) {
    // Inside here, `buf` has full static type `char (*)`
    for (size_t i = 0; i < sizeof(*buf); ++i) {
    // ...
    }
    }

    #define walk_auto(expr) _Generic((expr), \
    char (*): walk_array16_impl \
    )(expr)
    Use code with caution.

    C. __auto_type / __typeof__ Guarded Fallback

    If your target compilers are GCC or Clang, __typeof__ works even under
    -std=c11 (unlike bare typeof, double-underscore __typeof__ is accepted
    in strict ISO mode without warnings). You can isolate it behind a single portability macro if you ever need local variable inference:
    c
    #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
    #define C_TYPEOF(x) typeof(x)
    #elif defined(__GNUC__) || defined(__clang__)
    #define C_TYPEOF(x) __typeof__(x)
    #endif
    Use code with caution.

    3. Can the Compiler Inline static inline Functions Passed via Function Pointers?

    Yes?when the function pointer value is known at compile time (constant propagation), modern compilers (GCC, Clang, MSVC) devirtualize and
    inline static inline functions completely.

    When Inlining Succeeds (Zero Overhead)

    If you construct an adapter struct (or pass a function pointer) using a compile-time constant function name and pass that adapter into a static
    inline algorithm in the same translation unit:
    c
    typedef struct {
    const char* ptr;
    size_t len;
    int (*pred)(char c); // Typed function pointer inside the adapter
    } StrAdapter;

    static inline int is_digit_char(char c) {
    return c >= '0' && c <= '9';
    }

    static inline size_t count_matching(StrAdapter s) {
    size_t n = 0;
    for (size_t i = 0; i < s.len; ++i) {
    if (s.pred(s.ptr[i])) { // Indirect call in source...
    ++n;
    }
    }
    return n;
    }

    size_t example(const char* data, size_t len) {
    StrAdapter ad = { .ptr = data, .len = len, .pred = is_digit_char };
    // At -O2, the compiler sees `ad.pred == is_digit_char`, eliminates the
    // struct, devirtualizes `s.pred(...)`, and inlines `is_digit_char` into
    the loop.
    return count_matching(ad);
    }
    Use code with caution.
    ? Why static inline matters here: Marking both the predicate
    (is_digit_char) and the generic algorithm (count_matching) as static
    inline guarantees their AST/IR bodies are visible in the caller's
    translation unit. Under -O2, Scalar Replacement of Aggregates (SROA)
    unpacks StrAdapter into registers, sees the constant address
    &is_digit_char, and replaces the indirect call with the direct
    comparison instructions.

    When Inlining Cannot Happen

    ? Runtime-selected function pointers: If ad.pred is assigned
    conditionally at runtime (cond ? fn_a : fn_b) or loaded from an
    external/opaque translation unit without LTO (-flto), the compiler must
    emit an actual indirect call instruction.
    ? Comparing Compile-Time vs. Runtime Performance: Using static inline
    adapter algorithms + static inline callbacks gives you C++-template-like inlining whenever the adapter is constructed locally, while seamlessly degrading to a standard indirect function call whenever the adapter
    crosses an ABI boundary or is selected dynamically at runtime.

    Summary


    Goal C11 Mechanism Compile-Time Guarantee
    Function pointer dispatch _Generic((fn), Ret (*)(Arg): ...) Exact
    signature match (no implicit numeric coercion)
    Type inference without typeof _Generic ? static inline typed helper Type
    bound by helper parameter without naming it at call site
    Zero-cost callback inlining static inline algorithm + static inline
    callback Devirtualized & inlined at -O2 when pointer target is
    statically visible

    Would you like to see a complete, self-contained -std=c11 pattern for a
    generic sequence adapter (combining StrAdapter / ListAdapter with static
    inline predicates/transforms) that compiles down to a tight inlined loop
    under -O2?



    [ RF ]

    Thanks GG. Mostly I wanted to explore the features offered since
    _Generic that make for compile-time generification/specialization,
    particularly the account of the "zero-cost abstraction", then as with
    regards the run-time-type-identification, as for like "a vtable of
    pointers in C++", has that there are various accounts to consider for
    the run-time polymorphism, as the compile-time specialization is a bit
    sorted out.

    [ GG ]

    That gives a clean boundary: with compile-time specialization sorted out
    via _Generic + static inline zero-cost adapters, the remaining design
    space is runtime polymorphism in C11?how to structure runtime type identification (RTTI) and dynamic dispatch without sacrificing clarity,
    cache locality, or flexibility.
    In C11, there are four distinct architectures for runtime polymorphism.
    Each makes a different trade-off between memory overhead, openness to
    new types, and call indirection.

    1. The Four C11 Runtime Polymorphism Models


    Model Mechanism Open to New Types? Per-Instance Overhead Dispatch Cost
    Best For
    1. Tagged Union (enum + union) Explicit kind tag + switch Closed (fixed
    set of variants) sizeof(enum) + padding 1 direct branch (switch) Known
    adapter set (C-string, slice, sentinel list)
    2. Fat Pointer (Data + Vtable Ptr) { void* self; const Vtable* vptr; }
    Open (any translation unit) 1 pointer (8 bytes on 64-bit) 1 indirect
    call Non-intrusive interfaces (Rust/Go-style traits)
    3. Intrusive Vtable (vptr in Object) First struct member is const
    Vtable* Open (any translation unit) 1 pointer inside object 2 pointer dereferences Long-lived heap/pool objects (C++-style)
    4. Inline Function Pointers Function pointers stored directly in struct
    Open N pointers (N * 8 bytes) 1 direct register call Small adapters (1?2 callbacks, e.g., next, destroy)


    2. Deep Dive: Choosing the Right Runtime Representation


    A. Closed Set: Tagged Union (enum + union)

    When your runtime sequence adapters come from a known, bounded set of representations (e.g., null-terminated char*, length-prefixed LenSlice,
    and ListAdapter), a tagged union beats a vtable:
    ? No indirect calls: A switch statement lets the compiler inline the
    underlying static inline functions directly into the switch arms,
    keeping the instruction pipeline hot and branch-predictor friendly.
    ? Value semantics: The entire polymorphic adapter fits in 2?3 registers
    and lives on the stack with zero heap allocation.
    c
    typedef enum {
    ADAPTER_CSTR,
    ADAPTER_SLICE,
    ADAPTER_LIST
    } AdapterTag;

    typedef struct {
    AdapterTag tag;
    union {
    const char* cstr;
    LenSlice slice;
    ListAdapter list;
    } as;
    } RuntimeSeq;
    Use code with caution.

    B. Open Set & Non-Intrusive: Fat Pointer (Data* + const Vtable*)

    When external modules or plugins need to supply new sequence types
    without modifying a central enum, the fat pointer (conceptually
    identical to a Rust dyn Trait or Go interface) decouples the interface
    from the underlying data layout:
    ? Zero modification to existing types: A raw char[16] buffer, a file
    stream, or an intrusive node can all be adapted simply by defining a
    static const SeqVtable for each.
    ? Lightweight handle: Passing SeqView by value copies just two pointers
    (self and vptr).
    c
    typedef struct {
    int (*next)(void* self, void* out_elem);
    size_t (*remaining)(const void* self); // NULL if unknown/unbounded
    } SeqVtable;

    typedef struct {
    void* self;
    const SeqVtable* vptr;
    } SeqView;
    Use code with caution.
    Bonus RTTI capability: Because vptr points to a unique static const
    SeqVtable instance per concrete type, the address view.vptr itself acts
    as a unique runtime type ID (if (view.vptr == &CSTR_VTABLE)), giving you
    exact RTTI downcasting with zero extra tag bytes.

    C. Open Set & Minimal Adapter: Inline Function Pointers

    If an interface only has one or two operations (for example, a
    stream/generator with just next), storing the function pointer directly
    inside the struct avoids the double dereference (view.vptr->next) of a
    separate vtable:
    ? Faster dispatch: One fewer memory load before calling.
    ? Higher per-instance size if many methods exist: Once you exceed 2?3
    methods, factoring them into a shared const Vtable* saves stack/struct
    space.

    3. Bridging Compile-Time _Generic and Runtime Vtables

    You can unify your compile-time zero-cost layer and your runtime vtable/fat-pointer layer behind one _Generic front-end:
    1. Statically known types (char (*), LenSlice, ListAdapter) route
    directly to static inline functions?giving full inlining and zero-cost abstraction.
    2. Type-erased runtime handles (SeqView or RuntimeSeq) route to the vtable/switch dispatcher.
    3. Automatic lifting: A _Generic constructor macro (as_seq_view(x)) automatically pairs any concrete type x with its static const SeqVtable whenever you need to cross from compile-time generics into a runtime-polymorphic collection or boundary.
    c
    #define as_seq_view(x) _Generic((x), \
    LenSlice*: ((SeqView){ .self = (x), .vptr = &SLICE_VTABLE }), \
    ListAdapter*: ((SeqView){ .self = (x), .vptr = &LIST_VTABLE }), \
    SeqView: (x) \
    )
    Use code with caution.

    Decision Rule for Runtime Polymorphism in C11

    ? Use a Tagged Union (enum + union) when the set of adapter types is
    closed and controlled by your codebase (best performance, allows
    inlining inside switch).
    ? Use a Fat Pointer ({ void* self; const Vtable* vptr; }) when new types
    must plug in openly without touching central headers, and use vptr
    pointer equality as your zero-byte RTTI tag.
    ? Use Inline Function Pointers only when the interface has 1?2 methods
    and lives on the stack.
    Would you like to look at how to structure RTTI downcasting and
    capability queries (checking if an arbitrary SeqView supports random
    access or reset at runtime) using const Vtable* metadata fields?




    [ RF ]

    Thanks GG. Yes, I'd figure to use tagged-unions as that's a familiar
    account of polymorphic/variant types, then about for example having
    various leaf-types in the sources, then those having a general sort of wrapper-routine to a base-type, passing that into functions, and a
    general sort of unwrapper-routine within the function body, what I
    imagine would require explicit casting, that though being re-usable, and resulting returning a well-defined leaf-type. I might not expect to have inheritance more than 1-deep, i.e., would expect that a leaf-type's
    super-class is the base-type. There's that, then I'm looking about how
    to deal with holder-types, as alike generics, or like "optional" for
    example, about how to make for return-types of functions, that are
    covariant (or, variant), when for example returning values in the type convention or status/error codes in like "holder<T>".


    [ GG ]

    For a 1-level-deep hierarchy (leaf types ? single tagged-union base
    type) combined with generic Result<T> / Optional<T> holder return types, standard -std=c11 gives you clean, type-safe patterns that avoid manual
    casting boilerplate while keeping return types strictly typed.

    1. 1-Level Tagged Union: Type-Safe Wrap & Unwrap Without Manual Casts

    When every leaf type (LeafA, LeafB, LeafC) has a single base super-type (BaseVal), you can automate upcasting (wrapping) via _Generic and
    checked downcasting (unwrapping) via a macro that verifies the runtime
    tag before extracting the union member.

    Base & Leaf Definitions

    c
    #include <stddef.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include <assert.h>

    typedef enum {
    TAG_NONE = 0,
    TAG_SLICE,
    TAG_LIST,
    TAG_PAGE
    } BaseTag;

    typedef struct {
    const char* ptr;
    size_t len;
    } SliceLeaf;

    typedef struct {
    void* head;
    void* sentinel;
    } ListLeaf;

    typedef struct {
    char data[4096];
    } PageLeaf;

    // 1-level polymorphic base type
    typedef struct {
    BaseTag tag;
    union {
    SliceLeaf slice;
    ListLeaf list;
    PageLeaf page;
    } as;
    } BaseVal;
    Use code with caution.

    Automatic Upcast (wrap) via _Generic

    Instead of writing manual union initializers at every call site,
    _Generic matches the leaf's static type and constructs the tagged
    BaseVal in one step:
    c
    static inline BaseVal wrap_slice(SliceLeaf s) {
    return (BaseVal){ .tag = TAG_SLICE, .as.slice = s };
    }

    static inline BaseVal wrap_list(ListLeaf l) {
    return (BaseVal){ .tag = TAG_LIST, .as.list = l };
    }

    static inline BaseVal wrap_page(PageLeaf p) {
    return (BaseVal){ .tag = TAG_PAGE, .as.page = p };
    }

    // Upcasts any leaf type (or passes BaseVal through unchanged)
    #define wrap(x) _Generic((x), \
    SliceLeaf: wrap_slice, \
    ListLeaf: wrap_list, \
    PageLeaf: wrap_page, \
    BaseVal: (x) \
    )(x)
    Use code with caution.
    (Note: If x is already a BaseVal, add a static inline BaseVal
    wrap_id(BaseVal b) { return b; } so (x) works uniformly as a function call.)

    Checked Downcast (unwrap) Inside Functions

    Inside a function receiving BaseVal, you avoid raw pointer casts by
    mapping each leaf type to its expected BaseTag and union field name:
    c
    // Checked unwrap: asserts tag match and returns typed leaf by value
    #define unwrap_slice(b) (assert((b).tag == TAG_SLICE), (b).as.slice)
    #define unwrap_list(b) (assert((b).tag == TAG_LIST), (b).as.list)
    #define unwrap_page(b) (assert((b).tag == TAG_PAGE), (b).as.page)

    // Safe non-asserting pointer peek (returns NULL if tag does not match)
    static inline const SliceLeaf* try_as_slice(const BaseVal* b) {
    return (b && b->tag == TAG_SLICE) ? &b->as.slice : NULL;
    }
    Use code with caution.
    Because C11 returns SliceLeaf or ListLeaf by value directly from the
    union member, no explicit (LeafType*) cast is needed anywhere in user
    code, and strict aliasing rules are 100% respected.

    2. Generic Holder Types (Optional<T> & Result<T, Err>) in C11

    Because C11 does not have parametric templates (holder<T>), every
    distinct payload type T that crosses a function return boundary needs a concrete struct layout (Opt_SliceLeaf, Res_BaseVal, etc.).
    You can generate these cleanly from a single macro definition and bind
    uniform operations (is_ok, unwrap_or, err_code) across all holder instantiations using _Generic.

    Step 1: Compact Holder Generator Macro

    Keep the generator macro minimal so each type instantiation is a single readable line:
    c
    typedef enum {
    STATUS_OK = 0,
    STATUS_EOF,
    STATUS_INVALID_TAG,
    STATUS_OUT_OF_BOUNDS
    } StatusCode;

    // Declares `Opt_<T>` and `Res_<T>` in one line per payload type
    #define DEFINE_HOLDERS(T) \
    typedef struct { \
    bool has_val; \
    T val; \
    } Opt_##T; \
    \
    typedef struct { \
    StatusCode status; \
    T val; \
    } Res_##T

    // Instantiate only for your small set of return types
    DEFINE_HOLDERS(int);
    DEFINE_HOLDERS(SliceLeaf);
    DEFINE_HOLDERS(ListLeaf);
    DEFINE_HOLDERS(BaseVal);
    Use code with caution.

    Step 2: Uniform _Generic Accessors Across All Holders

    Even though Res_SliceLeaf and Res_BaseVal are distinct C struct types,
    _Generic lets you write polymorphic helper macros (is_ok(r),
    get_status(r)) that work uniformly on every holder type:
    c
    // Works on any Res_<T>
    #define is_ok(res) ((res).status == STATUS_OK)
    #define is_some(opt) ((opt).has_val)

    // Construct success or error holders cleanly using C99/C11 compound
    literals
    #define ok_res(ResType, value) \
    ((ResType){ .status = STATUS_OK, .val = (value) })

    #define err_res(ResType, code) \
    ((ResType){ .status = (code) })
    Use code with caution.

    Example: Function Returning a Typed Holder

    c
    Res_SliceLeaf next_slice(BaseVal* stream) {
    SliceLeaf* s = (stream && stream->tag == TAG_SLICE) ? &stream->as.slice
    : NULL;
    if (!s) {
    return err_res(Res_SliceLeaf, STATUS_INVALID_TAG);
    }
    if (s->len == 0) {
    return err_res(Res_SliceLeaf, STATUS_EOF);
    }
    SliceLeaf head = { .ptr = s->ptr, .len = 1 };
    ptr += 1;
    len -= 1;
    return ok_res(Res_SliceLeaf, head);
    }
    Use code with caution.

    3. Handling Variance / Covariance Across Holders in C11

    In languages with subtyping, if SliceLeaf is a subtype of BaseVal, then Res_SliceLeaf is covariant with Res_BaseVal (a function returning
    Res_SliceLeaf can satisfy a caller expecting Res_BaseVal).
    In C11, Res_SliceLeaf and Res_BaseVal are unrelated structs in the type
    system, so implicit conversion does not happen?but you can express
    explicit covariance cleanly with a single _Generic lift_res(...) adapter:
    c
    static inline Res_BaseVal lift_res_slice(Res_SliceLeaf r) {
    if (r.status != STATUS_OK) {
    return (Res_BaseVal){ .status = r.status };
    }
    return (Res_BaseVal){
    .status = STATUS_OK,
    .val = wrap_slice(r.val)
    };
    }

    static inline Res_BaseVal lift_res_list(Res_ListLeaf r) {
    if (r.status != STATUS_OK) {
    return (Res_BaseVal){ .status = r.status };
    }
    return (Res_BaseVal){
    .status = STATUS_OK,
    .val = wrap_list(r.val)
    };
    }

    // Covariant lift: converts any Res_<Leaf> into Res_BaseVal
    #define lift_to_base_res(res) _Generic((res), \
    Res_SliceLeaf: lift_res_slice, \
    Res_ListLeaf: lift_res_list, \
    Res_BaseVal: lift_res_id \
    )(res)
    Use code with caution.
    ? Leaf-returning functions (Res_SliceLeaf) preserve full static type
    precision without tag overhead when called directly.
    ? Polymorphic pipelines call lift_to_base_res(next_slice(&stream)) to
    propagate any error StatusCode untouched while automatically wrapping
    the payload into BaseVal.

    Architectural Summary


    Pattern C11 Implementation Why It Fits
    Upcast (Leaf ? Base) _Generic wrap(x) Zero manual tag assignment at call
    sites
    Downcast (Base ? Leaf) Checked union member access (unwrap_leaf(b)) No
    pointer casts; strict-aliasing safe
    Generic Holder (Res_<T>) One-line DEFINE_HOLDERS(T) + compound literals
    Carries both StatusCode and typed value by value
    Holder Covariance _Generic lift_to_base_res(r) Bridges specific
    Res_<Leaf> returns into Res_BaseVal

    Would you like to explore how to handle nested or recursive structures
    inside BaseVal (such as an adapter wrapping another BaseVal via
    pointer/arena) or ergonomic error-propagation macros (TRY(expr)
    early-return pattern in C11)?



    [ RF ]

    Thanks GG. This is going along well. Here the status codes might be
    particular among the return types in their own enums, yet it's according
    to some reserved failures and having both success_t and error_t and MODULE_SUCCESS_OK = 0 and MODULE_ERROR_ERRORLESS = 0, then to break out
    cases according to, for example, the "type_t" member, among these closed classes. For the purposes I have at the moment there are less than a
    handful of categories in a closed category. Comment as freely on the considerations and surrounds.

    [ GG ]

    Separating success_t (positive outcomes, 0 = standard OK, > 0 =
    domain-specific success nuances like EOF, PARTIAL, CACHED) from error_t (negative/failure outcomes, 0 = ERRORLESS, > 0 = reserved core faults + module-specific errors) gives you a rich, two-dimensional status model.
    When you have a closed category of fewer than a handful of module/return classes, pairing a type_t category discriminant with _Generic lets you
    inspect, route, and lift status codes uniformly without losing
    module-specific precision.

    1. The Two-Axis Status Model (success_t + error_t)

    Instead of cramming successes and errors into a single flat integer
    where callers guess whether 1 means "1 item read" or "Error #1", keeping
    them distinct in the holder clarifies control flow immediately:
    ? error_t (MODULE_ERROR_ERRORLESS = 0): Strictly reserved for faults.
    Any non-zero value means the payload val is invalid/uninitialized.
    ? Reserved Core Range (e.g., 1..31): Shared invariants across all
    modules (ERR_INVALID_TAG, ERR_OUT_OF_BOUNDS, ERR_NULL_ARG, ERR_NOMEM).
    ? Module-Specific Range (32+): Tailored to that specific return class (ERR_MALFORMED_UTF8, ERR_BROKEN_SENTINEL).
    ? success_t (MODULE_SUCCESS_OK = 0): Only meaningful when error == MODULE_ERROR_ERRORLESS.
    ? 0: Standard completion with a valid payload.
    ? > 0: Valid non-error completion states (SUCCESS_EOF, SUCCESS_EMPTY, SUCCESS_WOULD_BLOCK).
    c
    // Core reserved errors shared across all closed classes
    typedef enum {
    MOD_ERR_ERRORLESS = 0,
    MOD_ERR_INVALID_TAG = 1,
    MOD_ERR_OUT_OF_BOUNDS = 2,
    MOD_ERR_UNSUPPORTED = 3,
    MOD_ERR_RESERVED_MAX = 31
    } CoreError;

    // Module-specific enums extend cleanly above the reserved floor
    typedef enum {
    SEQ_ERR_ERRORLESS = MOD_ERR_ERRORLESS,
    SEQ_ERR_BAD_SENTINEL = 32,
    SEQ_ERR_TRUNCATED = 33
    } SeqError;

    typedef enum {
    SEQ_OK = 0,
    SEQ_OK_EOF = 1,
    SEQ_OK_PARTIAL = 2
    } SeqSuccess;
    Use code with caution.

    2. Breaking Out Cases via type_t Across a Closed Category

    With fewer than a handful of closed classes (say, CLASS_SLICE,
    CLASS_LIST, CLASS_PAGE), every holder or polymorphic result carries a
    type_t tag alongside its success_t and error_t.

    Uniform Holder Shape with type_t

    By placing type_t, error_t, and success_t in a consistent header layout
    across your closed classes, you can inspect any concrete holder
    (Res_Slice, Res_List) or the lifted Res_Base using the exact same
    branching logic:
    c
    typedef enum {
    TYPE_NONE = 0,
    TYPE_SLICE,
    TYPE_LIST,
    TYPE_PAGE
    } TypeKind;

    // Macro to stamp out typed holders with uniform status headers
    #define DEFINE_CLASS_HOLDER(TypeTag, PayloadT, SuccessEnum, ErrorEnum) \ typedef struct { \
    TypeKind type; \
    ErrorEnum err; \
    SuccessEnum ok; \
    PayloadT val; \
    } Res_##PayloadT

    DEFINE_CLASS_HOLDER(TYPE_SLICE, SliceLeaf, SeqSuccess, SeqError); DEFINE_CLASS_HOLDER(TYPE_LIST, ListLeaf, SeqSuccess, SeqError);
    Use code with caution.

    Dispatching on type_t in Control Flow

    Because the category is closed and small (3?4 cases), a direct switch (res.type) gives the compiler a dense jump table (or conditional moves)
    and guarantees exhaustiveness warnings (-Wswitch) whenever you add a new
    class:
    c
    void handle_any_result(Res_BaseVal r) {
    // 1. Fast-path fault check across all classes using the reserved core range
    if (r.err != MOD_ERR_ERRORLESS) {
    if (r.err <= MOD_ERR_RESERVED_MAX) {
    // Handle universal core error uniformly regardless of r.type
    return;
    }
    // Otherwise break out by closed class for module-specific error codes
    switch (r.type) {
    case TYPE_SLICE: /* inspect (SeqError)r.err */ break;
    case TYPE_LIST: /* inspect (SeqError)r.err */ break;
    case TYPE_PAGE: /* inspect (PageError)r.err */ break;
    case TYPE_NONE: break;
    }
    return;
    }

    // 2. Errorless path: break out by closed class and success nuance
    switch (r.type) {
    case TYPE_SLICE:
    if (r.ok == SEQ_OK_EOF) { /* ... */ }
    // safe to access r.val.as.slice
    break;
    case TYPE_LIST:
    // safe to access r.val.as.list
    break;
    case TYPE_PAGE:
    // safe to access r.val.as.page
    break;
    case TYPE_NONE:
    break;
    }
    }
    Use code with caution.

    3. Architectural Considerations & Surrounds

    When building around this pattern in -std=c11, four practical details
    keep the code clean and bug-free:
    ? Zero-Initialization Invariant (0 == ERRORLESS / OK / TYPE_NONE):
    Setting MODULE_ERROR_ERRORLESS = 0, MODULE_SUCCESS_OK = 0, and TYPE_NONE
    = 0 means {0} zero-initialization produces a valid, deterministic empty
    state (type == TYPE_NONE, no phantom error flags).
    ? Enum Underlying Type & ABI Stability:
    In C11, each enum is compatible with some implementation-defined integer
    type (int or unsigned int). When lifting a module-specific SeqError into
    a general Res_BaseVal, storing int err (or uint32_t err) in Res_BaseVal
    avoids enum-to-enum conversion warnings under -Wenum-conversion while preserving exact numeric equality (r.err == SEQ_ERR_TRUNCATED).
    ? Compile-Time _Generic + Runtime type_t Symmetry:
    Notice how type_t mirrors _Generic:
    ? At compile time, _Generic((x), SliceLeaf: TYPE_SLICE, ListLeaf:
    TYPE_LIST, ...) automatically stamps the right TypeKind into the struct
    so you never write .type = TYPE_SLICE by hand.
    ? At runtime, switch (res.type) recovers that exact compile-time
    distinction cleanly.
    ? Payload Validity Contract:
    Establish a strict rule across all closed classes: accessing .val is
    only legal when err == MOD_ERR_ERRORLESS (and optionally when ok == MODULE_SUCCESS_OK, if OK_EOF carries no item). Wrapping that check in a
    tiny static inline accessor prevents accidental reads of uninitialized
    union bytes on EOF or error paths.
    Would you like to see a small header layout showing how _Generic
    automatically stamps type_t on construction and lifts Res_<Leaf> into Res_BaseVal while preserving err and ok codes?



    [ RF ]

    Thanks GG. Carry on as freely.

    [ GG ]

    Everything we've discussed fits together into a single, cohesive
    -std=c11 pattern. Because your closed category has fewer than a handful
    of classes, you can pack the compile-time _Generic auto-stamping, the
    two-axis success_t / error_t status header, and the covariant
    lift_to_base bridge into one small header without macro bloat or runtime overhead.

    Complete -std=c11 Closed-Category Header Architecture


    1. Shared Core Status & Closed Category Tags

    By reserving 0 for ERRORLESS / OK / NONE and setting a floor (MOD_ERR_RESERVED_MAX = 31) for core errors, every module extends error
    and success codes cleanly without collisions.
    c
    #include <stddef.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include <assert.h>

    // Closed category discriminant
    typedef enum {
    TYPE_NONE = 0,
    TYPE_SLICE,
    TYPE_LIST,
    TYPE_PAGE
    } TypeKind;

    // Reserved core errors shared across all classes
    typedef enum {
    MOD_ERR_ERRORLESS = 0,
    MOD_ERR_INVALID_TAG = 1,
    MOD_ERR_OUT_OF_BOUNDS = 2,
    MOD_ERR_UNSUPPORTED = 3,
    MOD_ERR_RESERVED_MAX = 31
    } CoreError;

    typedef enum {
    MOD_OK = 0
    } CoreSuccess;
    Use code with caution.

    2. Leaf Types, Base Tagged Union, and Module Enums

    Each leaf carries its own compact layout (including fixed-size PageLeaf
    buffers by value), while BaseVal unifies them 1-level deep.
    c
    // Module-specific status enums (extending above reserved floor)
    typedef enum {
    SEQ_ERR_ERRORLESS = MOD_ERR_ERRORLESS,
    SEQ_ERR_BAD_SENTINEL = 32,
    SEQ_ERR_TRUNCATED = 33
    } SeqError;

    typedef enum {
    SEQ_OK = MOD_OK,
    SEQ_OK_EOF = 1,
    SEQ_OK_PARTIAL = 2
    } SeqSuccess;

    // Concrete leaf types
    typedef struct {
    const char* ptr;
    size_t len;
    } SliceLeaf;

    typedef struct {
    void* head;
    const void* sentinel;
    } ListLeaf;

    typedef struct {
    char data[64];
    } PageLeaf;

    // 1-level polymorphic base type
    typedef struct {
    TypeKind type;
    union {
    SliceLeaf slice;
    ListLeaf list;
    PageLeaf page;
    } as;
    } BaseVal;
    Use code with caution.

    3. Typed Holders (Res_<Leaf>) and Polymorphic Base Holder (Res_BaseVal)

    Each concrete return type keeps its exact SuccessEnum and ErrorEnum for
    strict -Wswitch checking at leaf call sites, while Res_BaseVal widens
    err and ok to int so any leaf result lifts losslessly.
    c
    #define DEFINE_CLASS_HOLDER(PayloadT, SuccessEnum, ErrorEnum) \
    typedef struct { \
    TypeKind type; \
    ErrorEnum err; \
    SuccessEnum ok; \
    PayloadT val; \
    } Res_##PayloadT

    DEFINE_CLASS_HOLDER(SliceLeaf, SeqSuccess, SeqError); DEFINE_CLASS_HOLDER(ListLeaf, SeqSuccess, SeqError); DEFINE_CLASS_HOLDER(PageLeaf, SeqSuccess, SeqError);

    // Lifted polymorphic holder (covariant target)
    typedef struct {
    TypeKind type;
    int err;
    int ok;
    BaseVal val;
    } Res_BaseVal;
    Use code with caution.

    4. Compile-Time _Generic Auto-Stamping & Covariant Lifting

    _Generic eliminates manual tag bookkeeping at every return statement and
    call site:
    ? type_tag_of(x) deduces TypeKind directly from any leaf value or pointer.
    ? ret_ok(ResT, val) / ret_status(ResT, ok_code) / ret_err(ResT,
    err_code) stamp the exact TypeKind automatically via _Generic on .val.
    ? lift_res(r) converts any concrete Res_<Leaf> into Res_BaseVal while preserving type, err, and ok intact.
    c
    // Deduce TypeKind at compile time from any leaf type
    #define type_tag_of(x) _Generic((x), \
    SliceLeaf: TYPE_SLICE, \
    ListLeaf: TYPE_LIST, \
    PageLeaf: TYPE_PAGE, \
    default: TYPE_NONE \
    )

    // Ergonomic holder constructors with automatic TypeKind stamping
    #define ret_ok(ResT, value) \
    ((ResT){ .type = type_tag_of(value), .err = 0, .ok = 0, .val = (value) })

    #define ret_ok_code(ResT, code, value) \
    ((ResT){ .type = type_tag_of(value), .err = 0, .ok = (code), .val =
    (value) })

    #define ret_err(ResT, zero_val, err_code) \
    ((ResT){ .type = type_tag_of(zero_val), .err = (err_code), .ok = 0 })

    // Concrete wrap helpers (Leaf -> BaseVal)
    static inline BaseVal wrap_slice(SliceLeaf s) {
    return (BaseVal){ .type = TYPE_SLICE, .as.slice = s };
    }

    static inline BaseVal wrap_list(ListLeaf l) {
    return (BaseVal){ .type = TYPE_LIST, .as.list = l };
    }

    static inline BaseVal wrap_page(PageLeaf p) {
    return (BaseVal){ .type = TYPE_PAGE, .as.page = p };
    }

    static inline BaseVal wrap_base(BaseVal b) {
    return b;
    }

    #define wrap(x) _Generic((x), \
    SliceLeaf: wrap_slice, \
    ListLeaf: wrap_list, \
    PageLeaf: wrap_page, \
    BaseVal: wrap_base \
    )(x)

    // Covariant holder lifters (Res_<Leaf> -> Res_BaseVal)
    static inline Res_BaseVal lift_slice_res(Res_SliceLeaf r) {
    return (Res_BaseVal){
    .type = r.type,
    .err = (int)r.err,
    .ok = (int)r.ok,
    .val = (r.err == SEQ_ERR_ERRORLESS) ? wrap_slice(r.val) : (BaseVal){0}
    };
    }

    static inline Res_BaseVal lift_list_res(Res_ListLeaf r) {
    return (Res_BaseVal){
    .type = r.type,
    .err = (int)r.err,
    .ok = (int)r.ok,
    .val = (r.err == SEQ_ERR_ERRORLESS) ? wrap_list(r.val) : (BaseVal){0}
    };
    }

    static inline Res_BaseVal lift_page_res(Res_PageLeaf r) {
    return (Res_BaseVal){
    .type = r.type,
    .err = (int)r.err,
    .ok = (int)r.ok,
    .val = (r.err == SEQ_ERR_ERRORLESS) ? wrap_page(r.val) : (BaseVal){0}
    };
    }

    static inline Res_BaseVal lift_base_res(Res_BaseVal r) {
    return r;
    }

    #define lift_res(r) _Generic((r), \
    Res_SliceLeaf: lift_slice_res, \
    Res_ListLeaf: lift_list_res, \
    Res_PageLeaf: lift_page_res, \
    Res_BaseVal: lift_base_res \
    )(r)
    Use code with caution.

    5. Putting It Together in Algorithm & Call-Site Code

    Notice how clean both the specialized leaf path and the polymorphic base
    path become:
    c
    // Specialized leaf routine: returns concrete Res_SliceLeaf with zero
    union overhead
    static inline Res_SliceLeaf slice_take_head(SliceLeaf* s) {
    if (!s || !s->ptr) {
    return ret_err(Res_SliceLeaf, (SliceLeaf){0},
    (SeqError)MOD_ERR_INVALID_TAG);
    }
    if (s->len == 0) {
    return ret_ok_code(Res_SliceLeaf, SEQ_OK_EOF, ((SliceLeaf){0}));
    }
    SliceLeaf out = { .ptr = s->ptr, .len = 1 };
    ptr += 1;
    len -= 1;
    return ret_ok(Res_SliceLeaf, out);
    }

    // Polymorphic routine: accepts BaseVal*, dispatches on type_t, lifts
    result covariantly
    Res_BaseVal base_take_head(BaseVal* b) {
    if (!b) {
    return (Res_BaseVal){ .type = TYPE_NONE, .err = MOD_ERR_INVALID_TAG };
    }
    switch (b->type) {
    case TYPE_SLICE:
    return lift_res(slice_take_head(&b->as.slice));
    case TYPE_LIST:
    // return lift_res(list_take_head(&b->as.list));
    return (Res_BaseVal){ .type = TYPE_LIST, .err = MOD_ERR_UNSUPPORTED };
    case TYPE_PAGE:
    return (Res_BaseVal){ .type = TYPE_PAGE, .err = MOD_ERR_UNSUPPORTED };
    case TYPE_NONE:
    default:
    return (Res_BaseVal){ .type = TYPE_NONE, .err = MOD_ERR_INVALID_TAG };
    }
    }
    Use code with caution.

    Why This Balance Works Well in -std=c11

    ? Zero-Cost Leaf Calls: Calling slice_take_head(&my_slice) directly
    never constructs a BaseVal or touches a switch; the compiler inlines it straight down to pointer arithmetic.
    ? Uniform Polymorphic Boundary: Calling base_take_head(&any_val) handles runtime polymorphism via a single dense switch (b->type) and reuses slice_take_head without duplicating logic.
    ? No Fragile Casts: Every unwrap (&b->as.slice) is guarded by its
    matching case TYPE_SLICE:, and every upcast (wrap, lift_res) is checked
    by _Generic at compile time.
    Would you like to add ergonomic propagation macros (e.g., TRY_LIFT(expr)
    to early-return errors/EOFs across functions returning Res_BaseVal or Res_<Leaf>) or diagnostic/string-mapping tables for logging TypeKind, CoreError, and module status codes?



    [ RF ]

    Thanks GG. Since you mentioned it, or them, both try-emulation and
    "char* from_enum(generic)" and "generic to_enum(char* name, type_t t)"
    would be of interest, then about try-emulation, about resulting "return(CATCHME)" or the like, carry on.

    [ GG ]

    Good to dive into both of these, RF. In strict -std=c11, you can build standard-compliant TRY propagation (without GNU statement expressions
    ({...})) and bidirectional enum reflection (from_enum / to_enum) that
    tie directly into your type_t and Res_<T> architecture.

    1. Standard -std=c11 TRY Emulation & return(CATCHME)

    In GCC/Clang, ({ ... }) statement expressions make TRY trivial, but in
    strict -std=c11 you cannot yield a value from a block statement.
    Instead, you use the out-parameter assignment pattern inside a do { ...
    } while (0) guard.

    A. Propagating Errors or Non-Zero Success (EOF) Automatically

    When a function returns any Res_<T> (whether a concrete Res_SliceLeaf or
    a lifted Res_BaseVal), TRY_ASSIGN evaluates the expression once, checks
    .err (and optionally .ok), and performs an immediate return?lifting the
    status cleanly to the caller's return type if needed.
    c
    // 1. Propagate faults (`err != 0`) while assigning `.val` on errorless
    paths
    #define TRY_ERR(out_var, expr, CallerResT) do { \
    Res_BaseVal _tmp_res = lift_res(expr); \
    if (_tmp_res.err != MOD_ERR_ERRORLESS) { \
    return (CallerResT){ \
    .type = _tmp_res.type, \
    .err = _tmp_res.err, \
    .ok = _tmp_res.ok \
    }; \
    } \
    (out_var) = (expr).val; \
    } while (0)
    Use code with caution.
    (To avoid double-evaluating expr in strict C11 when expr has side
    effects, pass a temporary holder or use a C_TYPEOF macro if targeting GCC/Clang, or pass the concrete ResT type name explicitly.)
    Here is the single-evaluation, zero-extension -std=c11 version by
    passing the expression's holder type ExprResT:
    c
    // Single-evaluation, strict -std=c11 TRY_ASSIGN
    #define TRY_ASSIGN(out_var, ExprResT, expr, CallerResT) do { \
    ExprResT _r = (expr); \
    if (_r.err != MOD_ERR_ERRORLESS) { \
    return (CallerResT){ \
    .type = _r.type, \
    .err = _r.err, \
    .ok = _r.ok \
    }; \
    } \
    (out_var) = _r.val; \
    } while (0)

    // Variant that ALSO short-circuits on non-zero success (e.g., SEQ_OK_EOF) #define TRY_OK(out_var, ExprResT, expr, CallerResT) do { \
    ExprResT _r = (expr); \
    if (_r.err != MOD_ERR_ERRORLESS || _r.ok != 0) { \
    return (CallerResT){ \
    .type = _r.type, \
    .err = _r.err, \
    .ok = _r.ok \
    }; \
    } \
    (out_var) = _r.val; \
    } while (0)
    Use code with caution.

    B. The return(CATCHME) Pattern (Local Block Trap / Single-Exit Cleanup)

    Sometimes you don't want to return from the entire function
    immediately?you want a local scope that catches any failure/EOF and
    jumps to a CATCHME: handler (for cleanup or recovery) before returning.
    c
    // Local try-block macro that jumps to label `catch_label` on failure
    #define TRY_CATCH(out_var, ExprResT, expr, caught_res, catch_label) do { \ ExprResT _r = (expr); \
    if (_r.err != MOD_ERR_ERRORLESS) { \
    (caught_res) = lift_res(_r); \
    goto catch_label; \
    } \
    (out_var) = _r.val; \
    } while (0)

    // Usage inside a function:
    Res_BaseVal parse_pair(SliceLeaf* stream) {
    Res_BaseVal caught = {0};
    SliceLeaf first = {0};
    SliceLeaf second = {0};

    TRY_CATCH(first, Res_SliceLeaf, slice_take_head(stream), caught, CATCHME); TRY_CATCH(second, Res_SliceLeaf, slice_take_head(stream), caught, CATCHME);

    return lift_res(ret_ok(Res_SliceLeaf, second));

    CATCHME:
    // Single cleanup / diagnostic hook before returning the caught status
    return caught;
    }
    Use code with caution.
    Notice how caught is a Res_BaseVal populated via lift_res(_r), so
    CATCHME: receives the exact type, err, and ok codes regardless of which
    leaf function failed.

    2. Bidirectional Enum Reflection: from_enum(generic) & to_enum(name, type_t)

    Because your closed category has a small, fixed set of enum types
    (TypeKind, CoreError, SeqError, SeqSuccess), you can generate both const
    char* from_enum(val) (dispatched via _Generic) and Res_EnumVal
    to_enum(const char* name, TypeKind t) (dispatched via type_t or an
    EnumKind tag) from a single compact table macro.

    Step 1: Single Source-of-Truth Enum Table

    Define each enum's entries once with a LIST(X) macro so string names and
    enum constants can never drift out of sync:
    c
    #include <string.h>

    #define TYPE_KIND_ENTRIES(X) \
    X(TYPE_NONE) \
    X(TYPE_SLICE) \
    X(TYPE_LIST) \
    X(TYPE_PAGE)

    #define SEQ_ERR_ENTRIES(X) \
    X(SEQ_ERR_ERRORLESS) \
    X(SEQ_ERR_BAD_SENTINEL) \
    X(SEQ_ERR_TRUNCATED)

    #define SEQ_OK_ENTRIES(X) \
    X(SEQ_OK) \
    X(SEQ_OK_EOF) \
    X(SEQ_OK_PARTIAL)
    Use code with caution.

    Step 2: from_enum(generic) via _Generic

    Each enum gets a tiny static inline const char* lookup function
    generated from its ENTRIES(X) list, and _Generic routes any enum value
    to its exact stringifier at compile time:
    c
    #define DEFINE_FROM_ENUM(EnumType, fn_name, ENTRIES_MACRO) \
    static inline const char* fn_name(EnumType v) { \
    switch (v) { \
    ENTRIES_MACRO(CASE_TO_STR) \
    default: return "UNKNOWN_" #EnumType; \
    } \
    }

    #define CASE_TO_STR(sym) case sym: return #sym;

    DEFINE_FROM_ENUM(TypeKind, type_kind_to_str, TYPE_KIND_ENTRIES) DEFINE_FROM_ENUM(SeqError, seq_err_to_str, SEQ_ERR_ENTRIES) DEFINE_FROM_ENUM(SeqSuccess, seq_ok_to_str, SEQ_OK_ENTRIES)

    // Polymorphic compile-time dispatch: works on any registered enum type
    #define from_enum(e) _Generic((e), \
    TypeKind: type_kind_to_str, \
    SeqError: seq_err_to_str, \
    SeqSuccess: seq_ok_to_str \
    )(e)
    Use code with caution.
    ? Zero runtime overhead: Calling from_enum(r.err) resolves directly to seq_err_to_str(r.err) at compile time?no string tables or hashes required.
    ? Compiler exhaustiveness: If you add a new enumerator to SeqError and
    forget to add it to SEQ_ERR_ENTRIES, -Wswitch warns you immediately.

    Step 3: to_enum(const char* name, type_t) Returning a Typed Holder

    For parsing a string back into an enum value, we know the target enum
    domain at runtime via a type_t / EnumDomain discriminant, and we return
    a Res_Int (or Res_BaseVal) holder using your two-axis status convention (MOD_ERR_INVALID_TAG on unknown string):
    c
    typedef enum {
    ENUM_DOMAIN_TYPE_KIND = 1,
    ENUM_DOMAIN_SEQ_ERR,
    ENUM_DOMAIN_SEQ_OK
    } EnumDomain;

    typedef struct {
    TypeKind type;
    int err;
    int ok;
    int val;
    } Res_Enum;

    #define IF_STR_MATCH(sym) \
    if (strcmp(name, #sym) == 0) { \
    return (Res_Enum){ .type = TYPE_NONE, .err = MOD_ERR_ERRORLESS, .val = (int)(sym) }; \
    }

    static inline Res_Enum to_enum(const char* name, EnumDomain domain) {
    if (!name) {
    return (Res_Enum){ .err = MOD_ERR_INVALID_TAG };
    }
    switch (domain) {
    case ENUM_DOMAIN_TYPE_KIND:
    TYPE_KIND_ENTRIES(IF_STR_MATCH)
    break;
    case ENUM_DOMAIN_SEQ_ERR:
    SEQ_ERR_ENTRIES(IF_STR_MATCH)
    break;
    case ENUM_DOMAIN_SEQ_OK:
    SEQ_OK_ENTRIES(IF_STR_MATCH)
    break;
    }
    return (Res_Enum){ .err = MOD_ERR_OUT_OF_BOUNDS };
    }
    Use code with caution.
    If you want to_enum to dispatch off your existing TypeKind (type_t) plus
    an axis selector (e.g., to_err_enum(name, r.type) vs. to_ok_enum(name, r.type)), you simply switch (t) on TypeKind so each closed class
    (TYPE_SLICE, TYPE_LIST, TYPE_PAGE) parses strings against its own module-specific ErrorEnum or SuccessEnum.

    Summary of How Everything Connects


    Construct Compile-Time or Runtime Mechanism Role in Your Architecture TRY_ASSIGN / TRY_CATCH Compile-time macro + runtime branch do { ... }
    while(0) + lift_res Propagates err/ok across leaf & base holders cleanly from_enum(e) Compile-time dispatch _Generic + switch over ENTRIES(X) Zero-overhead enum-to-string with -Wswitch safety
    to_enum(str, t) Runtime dispatch switch (t) + Res_Enum holder Parses
    strings into enum integers using your status model

    Would you like to look at arena/region-backed cleanup paired with the
    CATCHME label pattern (so heap or buffer allocations made inside a
    TRY_CATCH block roll back automatically on error)?



    [ RF ]

    Thanks GG. About passing allocator into these, would be as for the varying-parameter-count case as above, then basically about that
    allocator is considered other accounts like allocator/stdout/...,
    whatever is otherwise usually a "global function" to "club the globals", basically making holders of pointers, that would be built their specializations, according to type-inference on the expression, a
    relevant allocator and emitter for the expression its type.

    [ GG ]

    You are describing an explicit capability / environment context
    ("clubbing the globals" into a single typed capability bundle?allocator,
    output sink/emitter, logger?so nothing relies on hidden global state)
    paired with compile-time specialization via _Generic.
    In -std=c11, bundling globals into a capability struct (Env / Ctx) and
    routing operations through _Generic gives you two major benefits:
    1. Uniform arity without signature explosion: Instead of passing (alloc, stdout_sink, log_fn, ...) as separate parameters that blow up your
    _Generic arity macros, you pass one Ctx pointer (or omit it entirely via
    a 1-arg default overload).
    2. Type-inferred specialization of both allocator and emitter: _Generic inspects the target expression's type T and automatically binds the
    right alignment/size (sizeof(T), _Alignof(T)) for the allocator and the
    right formatting/serialization function (emit_slice, emit_list,
    emit_page) for the emitter.

    1. Clubbing the Globals: The Capability Bundle (EnvCtx)

    Instead of calling malloc, free, or fprintf(stdout, ...) directly inside
    your sequence adapters, group those interfaces into a lightweight
    capability struct:
    c
    #include <stddef.h>
    #include <stdint.h>
    #include <stdalign.h>

    // 1. Allocator capability
    typedef struct {
    void* (*alloc)(void* state, size_t size, size_t align);
    void (*free)(void* state, void* ptr, size_t size);
    void* state;
    } AllocCap;

    // 2. Emitter / sink capability (replaces direct stdout/stderr globals)
    typedef struct {
    int (*write_bytes)(void* state, const char* data, size_t len);
    void* state;
    } EmitCap;

    // 3. Clubbed environment bundle passed into routines
    typedef struct {
    AllocCap mem;
    EmitCap out;
    EmitCap err_out;
    } EnvCtx;
    Use code with caution.
    ? Zero global state: Unit tests pass an arena AllocCap and an in-memory
    buffer EmitCap; production passes a system/pool AllocCap and a FILE*
    EmitCap.
    ? Single parameter slot: Functions take (EnvCtx* ctx, ...) uniformly,
    keeping your parameter counts clean and predictable.

    2. Type-Inferred Allocator & Emitter Specialization via _Generic

    With EnvCtx in place, you can write type-inferred macros that inspect
    the expression passed in and automatically specialize both allocation (alloc_for(ctx, expr)) and emission (emit(ctx, expr)).

    A. Type-Inferred Allocation (alloc_as(ctx, expr))

    _Generic deduces the exact element type from an exemplar expression or
    typed pointer, automatically supplying sizeof(T) and _Alignof(T) without
    manual sizeof arithmetic:
    c
    // Typed allocation helpers (return NULL or typed pointer)
    static inline SliceLeaf* alloc_slice_impl(EnvCtx* ctx) {
    return (SliceLeaf*)ctx->mem.alloc(ctx->mem.state, sizeof(SliceLeaf), _Alignof(SliceLeaf));
    }

    static inline ListLeaf* alloc_list_impl(EnvCtx* ctx) {
    return (ListLeaf*)ctx->mem.alloc(ctx->mem.state, sizeof(ListLeaf), _Alignof(ListLeaf));
    }

    static inline PageLeaf* alloc_page_impl(EnvCtx* ctx) {
    return (PageLeaf*)ctx->mem.alloc(ctx->mem.state, sizeof(PageLeaf), _Alignof(PageLeaf));
    }

    // Type-inferred allocator dispatch: pass an exemplar value or typed pointer #define alloc_for(ctx, expr) _Generic((expr), \
    SliceLeaf: alloc_slice_impl, \
    SliceLeaf*: alloc_slice_impl, \
    ListLeaf: alloc_list_impl, \
    ListLeaf*: alloc_list_impl, \
    PageLeaf: alloc_page_impl, \
    PageLeaf*: alloc_page_impl \
    )(ctx)
    Use code with caution.
    ? Calling SliceLeaf* s = alloc_for(ctx, (SliceLeaf){0}); (or
    alloc_for(ctx, s)) infers SliceLeaf, passes the exact
    _Alignof(SliceLeaf), and returns a properly typed SliceLeaf* with zero
    manual casts at the call site.

    B. Type-Inferred Emitter (emit(ctx, expr))

    Similarly, emit(ctx, expr) inspects the static type of expr?whether a
    leaf (SliceLeaf, ListLeaf, PageLeaf), a BaseVal tagged union, or a
    Res_BaseVal status holder?and routes it to the matching formatter
    writing into ctx->out:
    c
    int emit_slice(EnvCtx* ctx, SliceLeaf s);
    int emit_list(EnvCtx* ctx, ListLeaf l);
    int emit_page(EnvCtx* ctx, PageLeaf p);
    int emit_cstr(EnvCtx* ctx, const char* s);
    int emit_base(EnvCtx* ctx, BaseVal b);
    int emit_res(EnvCtx* ctx, Res_BaseVal r);

    // Compile-time type inference selects the specialized emitter for `expr` #define emit(ctx, expr) _Generic((expr), \
    SliceLeaf: emit_slice, \
    ListLeaf: emit_list, \
    PageLeaf: emit_page, \
    char*: emit_cstr, \
    const char*: emit_cstr, \
    BaseVal: emit_base, \
    Res_BaseVal: emit_res \
    )((ctx), (expr))
    Use code with caution.
    And inside emit_base(EnvCtx* ctx, BaseVal b), you simply switch (b.type)
    and delegate to emit_slice, emit_list, or emit_page?reusing the exact
    same emitters for both compile-time _Generic calls and runtime type_t polymorphism.

    3. Handling Optional EnvCtx* via Arity Overloading

    If you want callers to be able to omit EnvCtx* when using a default
    environment (e.g., calling emit(val) with 1 argument vs. emit(ctx, val)
    with 2 arguments), your earlier arity counter macro handles both cleanly without duplicating implementations:
    c
    // Default fallback context (only referenced if 1-arg form is called)
    EnvCtx* default_env_ctx(void);

    #define EMIT_1(expr) emit_with_ctx(default_env_ctx(), (expr))
    #define EMIT_2(ctx, expr) emit_with_ctx((ctx), (expr))

    #define GET_EMIT_MACRO(_1, _2, NAME, ...) NAME
    #define emit_auto(...) \
    GET_EMIT_MACRO(__VA_ARGS__, EMIT_2, EMIT_1)(__VA_ARGS__)
    Use code with caution.
    ? emit_auto(my_slice) (1 arg) supplies default_env_ctx() and dispatches
    on my_slice's type.
    ? emit_auto(custom_ctx, my_slice) (2 args) uses custom_ctx directly
    without touching any global state.

    Architectural Payoff


    Concern How EnvCtx + _Generic Solves It
    No hidden globals Allocators, stdout/stderr, and loggers travel together
    in one EnvCtx* pointer.
    No arity explosion Adding a new capability (like a clock or tracer) adds
    a field to EnvCtx without changing any function signatures or _Generic
    tables.
    Zero-cost specialization When ctx->mem.alloc or ctx->out.write_bytes
    points to a static inline arena/buffer function in the same translation
    unit, -O2 inlines through the struct pointer cleanly.
    Unified compile-time & runtime _Generic routes statically typed
    expressions directly to emit_<Leaf>; emit_base switches on type_t and
    calls the exact same emit_<Leaf> functions.

    Would you like to see how to implement a minimal stack/arena AllocCap + memory-buffer EmitCap in ~25 lines of -std=c11 so you can drop this into
    a self-contained test harness right away?



    [ RF ]

    Thanks GG. It's considered a good sort of account how to pass down the "optional" parameters without polluting the signatures, then for those
    pointers to functions to get associated back with the relevant types
    after _Generic again keyed off the anchor/root signature-parameter type,
    then that it's not very, very much boilerplate then to have the code
    looking like it supports overloading of functions after type-inference,
    in C11, and with zero-cost abstraction for many accounts, and also for covariant return types, and, run-time polymorphism.

    [ GG ]

    That sums up the architecture cleanly, RF. By anchoring your dispatch on
    a single root parameter type via _Generic and threading optional
    capabilities (EnvCtx*) through a single context bundle, you get a
    remarkably cohesive system in pure -std=c11 without macro explosion or
    C++ complexity.

    Complete Architecture Recap: -std=c11 Polymorphic & Generic Toolkit


    Layer C11 Mechanism Guarantee & Cost
    Static Type Inference & Overloading _Generic anchored on the root
    parameter + arity counter macro (GET_MACRO) Zero-cost compile-time
    resolution; exact signature matching (including char (*)[N] and typed
    function pointers)
    Zero-Cost Specialization static inline leaf algorithms + static inline callbacks/capabilities Inlined & devirtualized at -O2 via SROA and
    constant propagation
    1-Level Runtime Polymorphism BaseVal tagged union (TypeKind + union)
    with _Generic wrap & switch unwrap Single-branch dispatch;
    strict-aliasing safe; zero raw pointer casts
    Two-Axis Status & Covariance Res_<Leaf> (error_t + success_t + type_t) + _Generic lift_res to Res_BaseVal Preserves reserved core faults (1..31),
    module errors (32+), and EOF nuances across subtype boundaries
    Control Flow & Reflection TRY_ASSIGN / TRY_CATCH (goto CATCHME) +
    from_enum / to_enum Single-evaluation early returns;
    exhaustiveness-checked enum stringification
    Clubbed Capabilities (No Globals) EnvCtx* bundling AllocCap + EmitCap, defaulted via 1-arg / 2-arg arity overload Clean signatures;
    deterministic testing with stack arenas and memory buffers


    Why This Stays Maintainable at Scale

    ? Linear Growth Only: Adding a new leaf type to your closed category
    requires adding one enum tag, one union field, and one line per _Generic dispatch table?never N ? M cross-product functions.
    ? Uniform Algorithm Source: Every algorithm is written once against
    concrete leaf types (SliceLeaf, ListLeaf, PageLeaf) as static inline
    functions, and both the compile-time _Generic path and the runtime
    switch (b->type) path call that exact same implementation.
    ? Strict Standards Portability: Everything compiles cleanly under
    -std=c11 -Wall -Wextra -Wpedantic -Wswitch with zero compiler extensions required.
    If you'd like, I can assemble a single, copy-pasteable reference header (poly_c11.h) containing all of these primitives together with a brief
    main() smoke test so you have a clean baseline to build on. Would that
    be useful?



    [ RF ]

    Thanks GG. It'd be of interest though that like other accounts like this session I'd use it for inspiration and write it my way, the account of
    the "poly_c11.h".

    [ GG ]

    That makes complete sense, RF?building your own clean implementation
    from first principles is the best way to keep every invariant tailored
    to your exact codebase and conventions.
    Here is a compact design checklist of the key C11 invariants we covered,
    useful as a quick mental reference while you draft your own header:
    ? Anchor on the Root Parameter: Keep _Generic tables single-level and
    anchored on the primary sequence/leaf expression, using GET_MACRO arity
    routing only when optional parameters (EnvCtx*, bounds, or sentinels)
    vary in count.
    ? Preserve Array Extents via Pointer-to-Array: Use char (*)[N] (or single-member value structs) whenever compile-time buffer sizes need to
    survive decay and distinguish branches in _Generic.
    ? Keep 0 as the Universal Zero-Init Invariant: Align TYPE_NONE = 0, MOD_ERR_ERRORLESS = 0, and MOD_OK = 0 so {0} initialization always
    yields a valid, deterministic empty state.
    ? Pair static inline Leaves with switch (type) Bases: Write algorithms
    once on concrete leaf types (static inline) so compile-time _Generic
    calls inline completely at -O2, while runtime BaseVal dispatch simply
    delegates inside a -Wswitch-checked switch.
    ? Lift Covariantly via _Generic: Keep module-specific ErrorEnum and
    SuccessEnum types intact on leaf holders (Res_<Leaf>), and use a single lift_res(...) macro to widen them into Res_BaseVal across polymorphic boundaries.
    ? Club Capabilities in One Context Pointer: Bundle allocators, emitters,
    and sinks into EnvCtx* so functions stay free of hidden global state
    without growing long parameter lists.
    Enjoy putting your own stamp on it, Ross?reach out anytime you want to
    bounce around edge cases or compiler diagnostics as you build it out.
    Whenever you're ready, feel free to share any compiler warnings
    (-Wpedantic, -Wswitch) or macro edge cases you run into while writing
    your version, and we can troubleshoot them together.



    [ RF ]

    Thanks GG. Alright then, if it's considered a demonstration of ability
    after possibility, emit "poly_c11.h".

    [ GG ]

    Here is a self-contained, strict -std=c11 -Wall -Wextra -Wpedantic
    -Wswitch reference header (poly_c11.h) demonstrating the complete architecture?compile-time _Generic overloading with arity routing,
    fixed-size array preservation, 1-level tagged-union RTTI, two-axis
    covariant holders, TRY_ASSIGN / TRY_CATCH, bidirectional enum
    reflection, and clubbed EnvCtx capabilities.
    c
    #ifndef POLY_C11_H
    #define POLY_C11_H

    #include <stddef.h>
    #include <stdint.h>
    #include <stdbool.h>
    #include <stdalign.h>
    #include <string.h>
    #include <assert.h>

    /* =========================================================================
    * 1. Closed Category Discriminants & Two-Axis Status Conventions
    *
    ========================================================================= */

    #define TYPE_KIND_ENTRIES(X) \
    X(TYPE_NONE) \
    X(TYPE_SLICE) \
    X(TYPE_LIST) \
    X(TYPE_PAGE)

    typedef enum {
    TYPE_NONE = 0,
    TYPE_SLICE,
    TYPE_LIST,
    TYPE_PAGE
    } TypeKind;

    typedef enum {
    MOD_ERR_ERRORLESS = 0,
    MOD_ERR_INVALID_TAG = 1,
    MOD_ERR_OUT_OF_BOUNDS = 2,
    MOD_ERR_UNSUPPORTED = 3,
    MOD_ERR_NO_MEMORY = 4,
    MOD_ERR_RESERVED_MAX = 31
    } CoreError;

    typedef enum {
    MOD_OK = 0
    } CoreSuccess;

    #define SEQ_ERR_ENTRIES(X) \
    X(SEQ_ERR_ERRORLESS) \
    X(SEQ_ERR_BAD_SENTINEL) \
    X(SEQ_ERR_TRUNCATED)

    typedef enum {
    SEQ_ERR_ERRORLESS = MOD_ERR_ERRORLESS,
    SEQ_ERR_BAD_SENTINEL = 32,
    SEQ_ERR_TRUNCATED = 33
    } SeqError;

    #define SEQ_OK_ENTRIES(X) \
    X(SEQ_OK) \
    X(SEQ_OK_EOF) \
    X(SEQ_OK_PARTIAL)

    typedef enum {
    SEQ_OK = MOD_OK,
    SEQ_OK_EOF = 1,
    SEQ_OK_PARTIAL = 2
    } SeqSuccess;

    /* =========================================================================
    * 2. Leaf Types, Fixed-Buffer Value Wrapper, & 1-Level Tagged Base
    *
    ========================================================================= */

    #ifndef POLY_PAGE_SIZE
    #define POLY_PAGE_SIZE 64
    #endif

    typedef struct {
    const char* ptr;
    size_t len;
    } SliceLeaf;

    typedef struct {
    void* head;
    const void* sentinel;
    } ListLeaf;

    typedef struct {
    _Alignas(max_align_t) char data[POLY_PAGE_SIZE];
    } PageLeaf;

    typedef struct {
    TypeKind type;
    union {
    SliceLeaf slice;
    ListLeaf list;
    PageLeaf page;
    } as;
    } BaseVal;

    /* =========================================================================
    * 3. Typed Class Holders & Covariant Base Holder
    *
    ========================================================================= */

    #define DEFINE_CLASS_HOLDER(PayloadT, SuccessEnum, ErrorEnum) \
    typedef struct { \
    TypeKind type; \
    ErrorEnum err; \
    SuccessEnum ok; \
    PayloadT val; \
    } Res_##PayloadT

    DEFINE_CLASS_HOLDER(SliceLeaf, SeqSuccess, SeqError); DEFINE_CLASS_HOLDER(ListLeaf, SeqSuccess, SeqError); DEFINE_CLASS_HOLDER(PageLeaf, SeqSuccess, SeqError);

    typedef struct {
    TypeKind type;
    int err;
    int ok;
    BaseVal val;
    } Res_BaseVal;

    /* =========================================================================
    * 4. Compile-Time Type Tagging, Wrapping, & Covariant Lifting
    *
    ========================================================================= */

    #define type_tag_of(x) _Generic((x), \
    SliceLeaf: TYPE_SLICE, \
    SliceLeaf*: TYPE_SLICE, \
    ListLeaf: TYPE_LIST, \
    ListLeaf*: TYPE_LIST, \
    PageLeaf: TYPE_PAGE, \
    PageLeaf*: TYPE_PAGE, \
    default: TYPE_NONE \
    )

    #define ret_ok(ResT, value) \
    ((ResT){ .type = type_tag_of(value), .err = 0, .ok = 0, .val = (value) })

    #define ret_ok_code(ResT, code, value) \
    ((ResT){ .type = type_tag_of(value), .err = 0, .ok = (code), .val =
    (value) })

    #define ret_err(ResT, zero_val, err_code) \
    ((ResT){ .type = type_tag_of(zero_val), .err = (err_code), .ok = 0 })

    static inline BaseVal wrap_slice(SliceLeaf s) {
    return (BaseVal){ .type = TYPE_SLICE, .as.slice = s };
    }

    static inline BaseVal wrap_list(ListLeaf l) {
    return (BaseVal){ .type = TYPE_LIST, .as.list = l };
    }

    static inline BaseVal wrap_page(PageLeaf p) {
    return (BaseVal){ .type = TYPE_PAGE, .as.page = p };
    }

    static inline BaseVal wrap_base(BaseVal b) {
    return b;
    }

    #define wrap(x) _Generic((x), \
    SliceLeaf: wrap_slice, \
    ListLeaf: wrap_list, \
    PageLeaf: wrap_page, \
    BaseVal: wrap_base \
    )(x)

    static inline Res_BaseVal lift_slice_res(Res_SliceLeaf r) {
    return (Res_BaseVal){
    .type = r.type,
    .err = (int)r.err,
    .ok = (int)r.ok,
    .val = (r.err == SEQ_ERR_ERRORLESS) ? wrap_slice(r.val) : (BaseVal){0}
    };
    }

    static inline Res_BaseVal lift_list_res(Res_ListLeaf r) {
    return (Res_BaseVal){
    .type = r.type,
    .err = (int)r.err,
    .ok = (int)r.ok,
    .val = (r.err == SEQ_ERR_ERRORLESS) ? wrap_list(r.val) : (BaseVal){0}
    };
    }

    static inline Res_BaseVal lift_page_res(Res_PageLeaf r) {
    return (Res_BaseVal){
    .type = r.type,
    .err = (int)r.err,
    .ok = (int)r.ok,
    .val = (r.err == SEQ_ERR_ERRORLESS) ? wrap_page(r.val) : (BaseVal){0}
    };
    }

    static inline Res_BaseVal lift_base_res(Res_BaseVal r) {
    return r;
    }

    #define lift_res(r) _Generic((r), \
    Res_SliceLeaf: lift_slice_res, \
    Res_ListLeaf: lift_list_res, \
    Res_PageLeaf: lift_page_res, \
    Res_BaseVal: lift_base_res \
    )(r)

    /* =========================================================================
    * 5. Standard -std=c11 TRY_ASSIGN & TRY_CATCH Propagation
    *
    ========================================================================= */

    #define TRY_ASSIGN(out_var, ExprResT, expr, CallerResT) do { \
    ExprResT _r = (expr); \
    if (_r.err != MOD_ERR_ERRORLESS) { \
    return (CallerResT){ \
    .type = _r.type, \
    .err = _r.err, \
    .ok = _r.ok \
    }; \
    } \
    (out_var) = _r.val; \
    } while (0)

    #define TRY_OK(out_var, ExprResT, expr, CallerResT) do { \
    ExprResT _r = (expr); \
    if (_r.err != MOD_ERR_ERRORLESS || _r.ok != 0) { \
    return (CallerResT){ \
    .type = _r.type, \
    .err = _r.err, \
    .ok = _r.ok \
    }; \
    } \
    (out_var) = _r.val; \
    } while (0)

    #define TRY_CATCH(out_var, ExprResT, expr, caught_res, catch_label) do { \ ExprResT _r = (expr); \
    if (_r.err != MOD_ERR_ERRORLESS) { \
    (caught_res) = lift_res(_r); \
    goto catch_label; \
    } \
    (out_var) = _r.val; \
    } while (0)

    /* =========================================================================
    * 6. Bidirectional Enum Reflection (from_enum / to_enum)
    *
    ========================================================================= */

    #define POLY_CASE_TO_STR(sym) case sym: return #sym;

    #define DEFINE_FROM_ENUM(EnumType, fn_name, ENTRIES_MACRO) \
    static inline const char* fn_name(EnumType v) { \
    switch (v) { \
    ENTRIES_MACRO(POLY_CASE_TO_STR) \
    default: return "UNKNOWN_" #EnumType; \
    } \
    }

    DEFINE_FROM_ENUM(TypeKind, type_kind_to_str, TYPE_KIND_ENTRIES) DEFINE_FROM_ENUM(SeqError, seq_err_to_str, SEQ_ERR_ENTRIES) DEFINE_FROM_ENUM(SeqSuccess, seq_ok_to_str, SEQ_OK_ENTRIES)

    #define from_enum(e) _Generic((e), \
    TypeKind: type_kind_to_str, \
    SeqError: seq_err_to_str, \
    SeqSuccess: seq_ok_to_str \
    )(e)

    typedef enum {
    ENUM_DOMAIN_TYPE_KIND = 1,
    ENUM_DOMAIN_SEQ_ERR,
    ENUM_DOMAIN_SEQ_OK
    } EnumDomain;

    typedef struct {
    TypeKind type;
    int err;
    int ok;
    int val;
    } Res_Enum;

    #define POLY_IF_STR_MATCH(sym) \
    if (strcmp(name, #sym) == 0) { \
    return (Res_Enum){ .type = TYPE_NONE, .err = MOD_ERR_ERRORLESS, .val = (int)(sym) }; \
    }

    static inline Res_Enum to_enum(const char* name, EnumDomain domain) {
    if (!name) {
    return (Res_Enum){ .err = MOD_ERR_INVALID_TAG };
    }
    switch (domain) {
    case ENUM_DOMAIN_TYPE_KIND:
    TYPE_KIND_ENTRIES(POLY_IF_STR_MATCH)
    break;
    case ENUM_DOMAIN_SEQ_ERR:
    SEQ_ERR_ENTRIES(POLY_IF_STR_MATCH)
    break;
    case ENUM_DOMAIN_SEQ_OK:
    SEQ_OK_ENTRIES(POLY_IF_STR_MATCH)
    break;
    }
    return (Res_Enum){ .err = MOD_ERR_OUT_OF_BOUNDS };
    }

    /* =========================================================================
    * 7. Clubbed Capabilities (Allocator & Emitter Context)
    *
    ========================================================================= */

    typedef struct {
    void* (*alloc)(void* state, size_t size, size_t align);
    void (*free)(void* state, void* ptr, size_t size);
    void* state;
    } AllocCap;

    typedef struct {
    int (*write_bytes)(void* state, const char* data, size_t len);
    void* state;
    } EmitCap;

    typedef struct {
    AllocCap mem;
    EmitCap out;
    EmitCap err_out;
    } EnvCtx;

    static inline SliceLeaf* alloc_slice_impl(EnvCtx* ctx) {
    return (SliceLeaf*)ctx->mem.alloc(ctx->mem.state, sizeof(SliceLeaf), _Alignof(SliceLeaf));
    }

    static inline ListLeaf* alloc_list_impl(EnvCtx* ctx) {
    return (ListLeaf*)ctx->mem.alloc(ctx->mem.state, sizeof(ListLeaf), _Alignof(ListLeaf));
    }

    static inline PageLeaf* alloc_page_impl(EnvCtx* ctx) {
    return (PageLeaf*)ctx->mem.alloc(ctx->mem.state, sizeof(PageLeaf), _Alignof(PageLeaf));
    }

    Use code with caution.
    #define alloc_for(ctx, expr) _Generic((expr),
    SliceLeaf: alloc_slice_impl,
    SliceLeaf*: alloc_slice_impl,
    ListLeaf: alloc_list_impl,
    ListLeaf*: alloc_list_impl,
    PageLeaf: alloc_page_impl,
    PageLeaf*: alloc_page_impl
    )(ctx)
    static inline int emit_cstr(EnvCtx* ctx, const char* s) {
    if (!ctx || !ctx->out.write_bytes || !s) {
    return -1;
    }
    return ctx->out.write_bytes(ctx->out.state, s, strlen(s));
    }
    static inline int emit_slice(EnvCtx* ctx, SliceLeaf s) {
    if (!ctx || !ctx->out.write_bytes || !s.ptr) {
    return -1;
    }
    return ctx->out.write_bytes(ctx->out.state, s.ptr, s.len);
    }
    static inline int emit_page(EnvCtx* ctx, PageLeaf p) {
    if (!ctx || !ctx->out.write_bytes) {
    return -1;
    }
    return ctx->out.write_bytes(ctx->out.state, p.data, sizeof(p.data));
    }
    static inline int emit_list(EnvCtx* ctx, ListLeaf l) {
    (void)l;
    return emit_cstr(ctx, "");
    }
    static inline int emit_base(EnvCtx* ctx, BaseVal b) {
    switch (b.type) {
    case TYPE_SLICE: return emit_slice(ctx, b.as.slice);
    case TYPE_LIST: return emit_list(ctx, b.as.list);
    case TYPE_PAGE: return emit_page(ctx, b.as.page);
    case TYPE_NONE:
    default: return emit_cstr(ctx, "");
    }
    }
    #define emit_with_ctx(ctx, expr) _Generic((expr),
    SliceLeaf: emit_slice,
    ListLeaf: emit_list,
    PageLeaf: emit_page,
    char*: emit_cstr,
    const char*: emit_cstr,
    BaseVal: emit_base
    )((ctx), (expr))
    /* =========================================================================
    ?
    8. Arity + Type Overloading Across Fixed Arrays, Slices, & C-Strings
    ?
    ========================================================================= */ static inline SliceLeaf slice_from_cstr(const char* s) {
    return (SliceLeaf){ .ptr = s, .len = s ? strlen(s) : 0 };
    }
    static inline SliceLeaf slice_from_ptr_len(const char* s, size_t len) {
    return (SliceLeaf){ .ptr = s, .len = len };
    }
    static inline SliceLeaf slice_from_arr64(char (*buf)[POLY_PAGE_SIZE]) {
    return (SliceLeaf){ .ptr = *buf, .len = sizeof(*buf) };
    }
    #define POLY_GET_MACRO(_1, _2, NAME, ...) NAME
    #define AS_SLICE_1(a) _Generic((a),
    char*: slice_from_cstr,
    const char*: slice_from_cstr,
    char (*)[POLY_PAGE_SIZE]: slice_from_arr64
    )(a)
    #define AS_SLICE_2(a, b) _Generic((a),
    char*: slice_from_ptr_len,
    const char*: slice_from_ptr_len
    )((a), (b))
    #define as_slice(...)
    POLY_GET_MACRO(VA_ARGS, AS_SLICE_2, AS_SLICE_1)(VA_ARGS)
    /* =========================================================================
    ?
    9. Zero-Cost Leaf Algorithm + Polymorphic Base Adapter
    ?
    ========================================================================= */ static inline Res_SliceLeaf slice_take_head(SliceLeaf* s) {
    if (!s || !s->ptr) {
    return ret_err(Res_SliceLeaf, (SliceLeaf){0},
    (SeqError)MOD_ERR_INVALID_TAG);
    }
    if (s->len == 0) {
    return ret_ok_code(Res_SliceLeaf, SEQ_OK_EOF, ((SliceLeaf){0}));
    }
    SliceLeaf head = { .ptr = s->ptr, .len = 1 };
    ptr += 1;
    len -= 1;
    return ret_ok(Res_SliceLeaf, head);
    }
    static inline Res_BaseVal base_take_head(BaseVal* b) {
    if (!b) {
    return (Res_BaseVal){ .type = TYPE_NONE, .err = MOD_ERR_INVALID_TAG };
    }
    switch (b->type) {
    case TYPE_SLICE:
    return lift_res(slice_take_head(&b->as.slice));
    case TYPE_LIST:
    return (Res_BaseVal){ .type = TYPE_LIST, .err = MOD_ERR_UNSUPPORTED };
    case TYPE_PAGE:
    return (Res_BaseVal){ .type = TYPE_PAGE, .err = MOD_ERR_UNSUPPORTED };
    case TYPE_NONE:
    default:
    return (Res_BaseVal){ .type = TYPE_NONE, .err = MOD_ERR_INVALID_TAG };
    }
    }
    #endif /* POLY_C11_H */

    <FollowUp>
    Feel free to adapt any piece of this layout into your own header?let me
    know if you want to test or refine any specific macro expansion or edge
    case.
    </FollowUp>



    [ RF ]

    Thanks GG. I'll share this and also later consult if for these sorts of
    ideas, though mostly I'm having some account of "u_alloc.h, u_stdio.h, u_lister.h", basically as an account of utils/utilities, then about the
    library boundaries which are of interest, "m_cfg.h, m_pro.h, m_res.h",
    or as alike "m_cnfg.h, m_prto.h, m_rsrc.h", those then having some
    accounts of common types, for examples about the utils, and own types,
    about the conventions and their functions and so on (their classes).


    [ GG ]

    That layering?separating foundational utilities (u_*.h) from
    domain/protocol modules (m_*.h)?maps cleanly onto the C11 polymorphism
    and capability patterns we just built.

    Architectural Layering (u_*.h vs. m_*.h)


    Layer Headers Primary Responsibility Key Types & Patterns
    Core Status & Base Primitives u_base.h (or shared prelude) Closed
    category tags, core error floor (0..31), BaseVal, TRY_*, from_enum /
    to_enum TypeKind, CoreError, Res_BaseVal, EnvCtx
    Utility Capabilities (u_*) u_alloc.h, u_stdio.h, u_lister.h Concrete
    capability implementations & generic container/sequence adapters
    AllocCap (arenas/pools), EmitCap (FILE*/buffers), SliceLeaf, ListLeaf (null/sentinel)
    Module Boundaries (m_*) m_cnfg.h, m_prto.h, m_rsrc.h Domain-specific
    state machines, wire protocols, and resource lifecycles Module-specific ErrorEnum (32+) & SuccessEnum, Res_<ModuleObj>, lifted to Res_BaseVal


    Key Boundary Conventions

    ? Shared Core vs. Module-Owned Enums: Keep CoreError (0..31) and
    TypeKind in the utility base so u_alloc.h, u_stdio.h, and u_lister.h
    never depend on m_* headers. Each m_*.h module defines its own ErrorEnum starting at 32 (e.g., CNFG_ERR_PARSE = 32, PRTO_ERR_FRAMING = 32, RSRC_ERR_EXHAUSTED = 32) while lifting seamlessly into Res_BaseVal
    across module boundaries.
    ? Capability Injection Across Boundaries: u_alloc.h and u_stdio.h
    provide the concrete AllocCap and EmitCap adapters that populate EnvCtx.
    The m_*.h modules accept EnvCtx* as their root context parameter and
    dispatch via _Generic (alloc_for(ctx, expr), emit_with_ctx(ctx, expr)),
    keeping every module 100% free of direct malloc or stdout calls.
    ? Sequence Adapters (u_lister.h) as the Glue: u_lister.h houses the
    sequence views (SliceLeaf, null-linked and sentinel-linked ListLeaf,
    fixed PageLeaf) so m_cnfg.h (config parsing), m_prto.h (protocol
    framing), and m_rsrc.h (resource descriptors) all consume and emit
    uniform sequences without duplicating traversal code.
    Whenever you're ready to sketch out the interfaces or contracts for
    u_lister.h or the m_cnfg.h / m_prto.h / m_rsrc.h module boundaries, we
    can pick right up from here, RF.
    Would you like to look at how u_lister.h can unify null-link and
    sentinel-link lists under a single _Generic interface, or how m_cnfg.h / m_prto.h / m_rsrc.h register their module-specific status enums into the
    shared reflection tables?



    [ RF ]

    Thanks GG. I figure this is quite a fair amount of material to digest,
    and that it well goes to show that since C11 that accounts of
    type-inference and compile-time and later run-time generification/specialization/overloading and polymorphism and covariant return-types, that the type-appease makes for that the compiler may be
    greatly appeased as with regards to type-safety and neither much
    boilerplate, macros, nor the explosion of code under combinatorics.

    [ GG ]

    That captures the exact takeaway, RF. Modern C11 gives you a clean sweet
    spot where the compiler's type system works with you rather than
    requiring heavy macro code generation or C++ template machinery:
    ? Static Type Safety Without Combinatorial Bloat: _Generic acts as a
    thin, zero-cost compile-time router anchored on your root types, while
    static inline leaf algorithms let the optimizer collapse abstractions
    down to direct instructions.
    ? Clean Runtime Boundaries: A 1-level tagged union (BaseVal) paired with two-axis covariant holders (Res_<T> ? Res_BaseVal) bridges compile-time precision and runtime polymorphism without raw pointer casts or loss of
    status detail.
    ? Modular Independence: Threading capabilities through a single EnvCtx*
    keeps your u_* utilities and m_* domain modules decoupled, testable, and
    free of hidden global state.
    Take your time digesting and shaping it into your u_* and m_* headers,
    Ross?it was a pleasure working through the design with you. Reach out
    whenever you're ready for the next piece.
    Whenever you want to continue, we can dive into u_lister.h (unifying null-linked and sentinel-linked list adapters) or m_cnfg.h / m_prto.h / m_rsrc.h module boundary contracts.



    [ RF ]

    Thanks GG. I imagine that if there are any perceived questions or
    problems, now's the time to raise them.


    [ GG ]

    If you are stepping into drafting u_alloc.h, u_stdio.h, u_lister.h, and
    the m_*.h modules right now, there are five subtle C11 traps worth
    keeping on your radar so they don't trip up your compiler or cause
    subtle UB later:

    1. Qualifier Sensitivity in _Generic (const Pointers)

    _Generic strips top-level qualifiers from values (const int matches
    int), not from pointed-to types (const SliceLeaf* does not match
    SliceLeaf*).
    ? Trap: If a helper function receives const SliceLeaf* s and calls type_tag_of(s) or emit_with_ctx(ctx, s), compilation fails unless const SliceLeaf* is listed alongside SliceLeaf* in the _Generic association table.
    ? Fix: Consistently register both T* and const T* in pointer-accepting
    _Generic maps.

    2. Integer Promotion in _Generic Controlling Expressions

    In C11, _Generic does not perform default integer promotions on the
    controlling expression, yet character constants like 'a' have type int
    in C (unlike char in C++).
    ? Trap: If you dispatch on char vs. int (or uint8_t vs. enum), passing
    'x' matches int, while passing a char variable matches char. Also, two
    enum types that share the same underlying integer representation can
    trigger a "compatible types in _Generic" error on certain compilers if
    placed in the same _Generic block without distinct wrapper structs or
    distinct underlying ranges.
    ? Fix: Test your _Generic enum tables under both GCC and Clang with
    -Wpedantic early, since C11 leaves the exact underlying integer type of
    each enum implementation-defined.

    3. Enum Collision When Lifting m_cnfg.h, m_prto.h, and m_rsrc.h

    Each module (m_cnfg.h, m_prto.h, m_rsrc.h) can safely start its own
    ErrorEnum at 32 (MOD_ERR_RESERVED_MAX + 1), provided every Res_BaseVal
    carries its TypeKind / ModuleKind discriminant alongside int err.
    ? Trap: If a caller checks if (res.err == CNFG_ERR_PARSE) on a
    Res_BaseVal without first checking res.type == MOD_CNFG, a
    PRTO_ERR_FRAMING (also 32) will false-positive as a config parse error.
    ? Fix: Enforce a strict invariant: module-specific error codes (>= 32)
    are only inspected inside a switch (res.type) branch; outside the
    switch, only core errors (1..31) are compared directly.

    4. Return-by-Value ABI Cost on Large PageLeaf Holders

    Small structs like SliceLeaf (16 bytes) and ListLeaf (16 bytes) return
    in two CPU registers (RAX/RDX on x86-64, X0/X1 on ARM64) with zero
    memory traffic.
    ? Trap: Once PageLeaf (char data or 4096) is embedded inside BaseVal and Res_BaseVal, returning Res_BaseVal by value copies the entire union size
    via a hidden stack pointer (sret) on every call, even when returning a
    tiny SliceLeaf or an error.
    ? Fix: Keep value-embedded buffers in BaseVal small (e.g., <= 64 bytes),
    or have PageLeaf hold a char (*page) pointer-to-array so BaseVal stays
    fixed at 24?32 bytes regardless of page size.

    5. Include-Order & Open Registration Across u_* and m_*

    Because _Generic tables are closed at the point where the macro expands, u_base.h cannot list m_cnfg.h types unless u_base.h knows about them?or
    unless each m_*.h defines its own module-local _Generic wrapper that
    delegates to u_base.h for core types in its default: branch.
    ? Fix: Use default: chaining: m_cnfg.h defines cnfg_emit(ctx, x) with
    default: emit_with_ctx(ctx, x). That keeps u_*.h 100% decoupled from
    m_*.h while giving module code a single unified macro call.
    Everything else is on solid ground, RF?those five invariants will save
    you any surprises as you lay out the headers.
    Would you like to examine default: chaining across u_*.h and m_*.h in a
    quick snippet before you start writing your headers, or are you all set
    to dive in?



    [ RF ]

    Thanks GG. That'll do and is a nice exposition. I'll transcribe this and
    later consult it when mostly working on the "library interface
    conventions & idiom & discipline & design" and "component interface
    conventions & ...".

    [ GG ]

    You're very welcome, RF. That will serve as a solid blueprint when you
    sit down to formalize your library and component interface conventions
    across u_*.h and m_*.h.
    Enjoy the transcription and the design work ahead, Ross?reach out
    anytime you're ready for the next round.
    Whenever you pick up the library and component interface conventions
    again, feel free to drop in a draft header or interface contract to
    review together.

    [ RF ]

    Thanks GG. Good-day, good-bye.

    [ GG ]

    Good-day, RF. Good-bye!

















    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Wed Nov 18 20:40:40 2026
    On 18/11/2026 19:58, Ross Finlayson wrote:

    <More than 3300 lines snipped>

    You're a nutter.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed Nov 18 13:14:08 2026
    On 11/18/2026 2:30 AM, Ross Finlayson wrote:
    On 11/17/2026 03:46 PM, Chris M. Thomasson wrote:
    On 11/17/2026 1:00 AM, Ross Finlayson wrote:
    On 11/16/2026 01:10 PM, Chris M. Thomasson wrote:
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the
    connection-oriented or datagram-wise or association-oriented like >>>>>>> TCP, UDP, or SCTP, and it manages the connecting and the sending and >>>>>>> receiving about a million of those and is sort of fixed-size and >>>>>>> stable in a usual runtime. So, how do you design the interface,
    about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example >>>>>>> the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort
    of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote, perhaps >>>> not. Sigh.



    About epoll and dropping reads, it's not the same as io_uring
    which has fixed-sized queues and if it gets full drops those
    in the kernel, it's about the edge-triggered case or "e"-poll
    for edge-triggered poll, vis-a-vis the usual account of poll
    or select or pselect as level-triggered, that there's perceived
    to be an edge case where epoll would lose notice of a notification.
    The idea is that while blocking in epoll_wait, that the process
    gets a signal, then, the kernel interrupts and runs the signal-handler
    and returning from epoll_wait it gets EINTR, _or_, according to
    a policy of whether to re-try blocking sys-calls the kernel interrupts
    and runs the signal-handler and the process enters epoll_wait again.

    So, I'm under the impression that there's a race-condition where
    the process gets a signal while blocked in epoll_wait, then according
    to one of two policies, EAGAIN error-handling or re-try, that it
    loses the notification, not the packet. The packet is still on
    the socket to be read, the notification of it was lost.

    The pselect simply doesn't have that problem, it's level-triggered,
    and however it re-enters pselect after getting interrupted,
    as long as there's data yet to read, it will get notified.


    Then also epoll might not need mlock'ed memory like io_uring does.



    That's about it.





    pselect() is simple, portable, and for many workloads fast enough. Those
    are perfectly valid engineering arguments.

    For a high-performance server, though, well, shit. I personally wouldn't
    be reaching for pselect() at all. Uggg...

    One thing I like about mechanisms such as io_uring and IOCP is that they
    encourage thinking about capacity up front. You tend to preallocate the
    resources the system needs to operate, size your queues and pools
    appropriately, and define behavior for resource pressure. Thats
    generally preferable to discovering in the god damn hot path that yet
    another allocation is required! Fuck!

    On Windows, large scale IOCP servers have long used techniques such as
    so called, zero byte receives, and preallocated connection state to
    reduce memory pressure and avoid per-operation allocations. Similar
    ideas apply elsewhere, for sure. The goal is usually to enter a pressure
    mode before critical resources are exhausted, not to keep allocating
    indefinitely and hope for the best.

    When resources start getting tight, I would rather see the server shed
    load, evict caches, shorten timeouts, disconnect stale clients, or
    refuse new work than continue consuming memory until the operating
    system is in trouble. Running out of capacity should be a planned state,
    not a surprise.

    That's one of the reasons fixed pools and preallocated state appeal to
    me for systems under heavy load.


    Preallocated state is another matter altogether, this sort of approach mentioned presumes fixed resources, for example when a memory-pool is
    in-use, to stop reads and then TCP/IP itself closes the receive window.

    Preallocated state is a nice way to get a 100% guarantee that everything
    works as-is. If any more (extra) connections come in, at least in IOCP
    we can use several means to expand the state. If we succeeded tag the
    per_io and/or per_socket state with being "outside" of the pool. So on shutdown, graceful close, aborted, etc. We know well, perhaps we need to
    call free, or whatever, or even closesocket. With IOCP we can create all
    of our sockets up front if we want. The windozer has that fun:

    https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms737757(v=vs.85)

    It allows a socket to be reused in either AcceptEx or ConnectEx:

    https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock-acceptex

    https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nc-mswsock-lpfn_connectex

    With io_uring, we would want to dedicate the whole box, or a part of it,
    to be okay. This is for IO. Ideally we preallocate as much as the box
    can handle without caking its pants.




    The "pressure" closes the receive-side, and clients wait (the network buffers).

    These aren't necessarily huge nodes with vertical scaling, they're
    mid-sized boxen that have to share all the resources with many other processes.

    So, we may entirely separate fixed-size allocations and
    notification/polling subsystems as concerns, about the
    box: and the network.

    For example, then often these are virtualized/containerized
    mid-size boxen, where it's not only that processes shouldn't
    contend/thrash with the allocator: also when there's memory-pressure
    that the biggest one gets booted, or "OOMKiller".


    Then, for example, since the box already has connection limits,
    and, for example, these get exhausted before this sort of
    "I/O-handle-bound process-model", it naturally throttles itself.
    Where pselect() has a limit of FD_SETSIZE handles, of open connections,
    and furthermore the numbered file-descriptors must be less than
    FD_SETSIZE, then scaling out in child-processes or workers/laborers,
    is old-fashioned and stable.

    launcher <- eg, systemd, privileged port
    leader <- 1,000-many potential laborers (child processes), fixed-heap listener <- accepts TCP or 1,000-many potential UDP "connections"
    laborer(s) <- 1,000-many potential connections
    logger <- funnels the logs
    logmet <- funnels the metrics
    logdmp <- funnels dumps
    loconsole <- optional REPL

    This is "1,000-many file-descriptors for connections, a dozen
    for a 'process-protocol' among the 'process-tree' the 'process-group',
    and 0/1/2 being stdin/stdout/stderr and 4/5/6 being
    'stdlog/stdmet/stddmp'", that being an "I/O-handle-bounde process-model".


    It makes sense that a hog with the flops on dedicated hardware
    can use all the resources for itself, that not usually being the case.
    The "thinking about capacity up-front" is a great idea, here that
    nobody knows what the front-end and back-end capacity will eventually
    be, for protocols like TCP/IP that "surface the pressure" and a box
    that doesn't burst under the burst-y.


    It's appreciated these sorts of accounts.




    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed Nov 18 13:18:28 2026
    On 11/18/2026 1:14 PM, Chris M. Thomasson wrote:
    On 11/18/2026 2:30 AM, Ross Finlayson wrote:
    On 11/17/2026 03:46 PM, Chris M. Thomasson wrote:
    On 11/17/2026 1:00 AM, Ross Finlayson wrote:
    On 11/16/2026 01:10 PM, Chris M. Thomasson wrote:
    On 11/16/2026 12:04 PM, Ross Finlayson wrote:
    On 11/16/2026 10:09 AM, Bonita Montero wrote:
    Am 13.11.2026 um 23:50 schrieb Ross Finlayson:

    So, here's one. Say you got a server process for sockets of the >>>>>>>> connection-oriented or datagram-wise or association-oriented like >>>>>>>> TCP, UDP, or SCTP, and it manages the connecting and the sending >>>>>>>> and
    receiving about a million of those and is sort of fixed-size and >>>>>>>> stable in a usual runtime. So, how do you design the interface, >>>>>>>> about stuff like the state-machine of _protocols_, all about
    _protocols_, in the application-layer and above, say, for example >>>>>>>> the incremental-parsing and the state-machine of the protocol
    and sub-protocols and upgrade-protocols and the like, what sort >>>>>>>> of abstraction with suitable-defaults and reasonable-opinions
    makes for having any sort protocol as a composable library.
    Use C++20 coroutines with Bost.ASIO and io_uring. This gives
    as less code as possible with nearly optimal I/O performance.

    Thanks for writing Bonita. I'd infer from "schrieb" that
    your user-agent locale country/language is DE/de or as
    variously for example about 2-letter and 3-letter country
    codes and accounts of language or ISO 601 or what I forget.
    Mann kann nur kleine Deutsch gesprechern, nicht viel das
    hier doch, aber los. Mein Wortschatz, es ist kaput.


    That said, _why_ I specifically am not using epoll/kqueue
    or io_uring instead pselect not select or poll, is:
    if you overload the epoll red/black tree or io_iuring queues
    respectively, they drop messages. Now, most of the time,
    that's accommodated by some absurdly simple back-end like
    "send" that tolerates drops itself, in things like message-bus.
    Then, epoll for example, on a wake-up or return from the blocking
    syscall, doesn't notify twice when there remains data to be read.
    Then, pselect() may be blocking and furthermore with the impact
    that the kernel polls the sockets busily, yet, pselect() can
    timeout itself, for example, and register interest on active
    selectors and only periodically eg 5ms register interest on
    active + inactive selectors (file-descriptors).

    Then, there's a fact that POSIX runtimes have signals,
    then, that pselect() behaves in a more defined manner.

    Another key distinction is that: buffers for use with
    epoll and I believe also kqueue, or io_uring, must
    be "pinned" with mlock() or what, to physical memory,
    for the kernel to treat them, instead of copying from
    user-space to kernel-space or vice-versa or however
    the runtime may care to swap pages under addresses
    with making copies, that for accounts of vector I/O,
    scatter/gather yet mostly vector I/O for the bus boss
    the DMA, it's just plain old heap RAM.


    Then, also pselect() is POSIX and so it's portable.
    It's less code if it doesn't need multiple back-ends
    for various platforms' implementations of I/O multiplexing.



    Huh? Do you have a clue at all about this? From what you wrote,
    perhaps
    not. Sigh.



    About epoll and dropping reads, it's not the same as io_uring
    which has fixed-sized queues and if it gets full drops those
    in the kernel, it's about the edge-triggered case or "e"-poll
    for edge-triggered poll, vis-a-vis the usual account of poll
    or select or pselect as level-triggered, that there's perceived
    to be an edge case where epoll would lose notice of a notification.
    The idea is that while blocking in epoll_wait, that the process
    gets a signal, then, the kernel interrupts and runs the signal-handler >>>> and returning from epoll_wait it gets EINTR, _or_, according to
    a policy of whether to re-try blocking sys-calls the kernel interrupts >>>> and runs the signal-handler and the process enters epoll_wait again.

    So, I'm under the impression that there's a race-condition where
    the process gets a signal while blocked in epoll_wait, then according
    to one of two policies, EAGAIN error-handling or re-try, that it
    loses the notification, not the packet. The packet is still on
    the socket to be read, the notification of it was lost.

    The pselect simply doesn't have that problem, it's level-triggered,
    and however it re-enters pselect after getting interrupted,
    as long as there's data yet to read, it will get notified.


    Then also epoll might not need mlock'ed memory like io_uring does.



    That's about it.





    pselect() is simple, portable, and for many workloads fast enough. Those >>> are perfectly valid engineering arguments.

    For a high-performance server, though, well, shit. I personally wouldn't >>> be reaching for pselect() at all. Uggg...

    One thing I like about mechanisms such as io_uring and IOCP is that they >>> encourage thinking about capacity up front. You tend to preallocate the
    resources the system needs to operate, size your queues and pools
    appropriately, and define behavior for resource pressure. Thats
    generally preferable to discovering in the god damn hot path that yet
    another allocation is required! Fuck!

    On Windows, large scale IOCP servers have long used techniques such as
    so called, zero byte receives, and preallocated connection state to
    reduce memory pressure and avoid per-operation allocations. Similar
    ideas apply elsewhere, for sure. The goal is usually to enter a pressure >>> mode before critical resources are exhausted, not to keep allocating
    indefinitely and hope for the best.

    When resources start getting tight, I would rather see the server shed
    load, evict caches, shorten timeouts, disconnect stale clients, or
    refuse new work than continue consuming memory until the operating
    system is in trouble. Running out of capacity should be a planned state, >>> not a surprise.

    That's one of the reasons fixed pools and preallocated state appeal to
    me for systems under heavy load.


    Preallocated state is another matter altogether, this sort of approach
    mentioned presumes fixed resources, for example when a memory-pool is
    in-use, to stop reads and then TCP/IP itself closes the receive window.

    Preallocated state is a nice way to get a 100% guarantee that everything works as-is. If any more (extra) connections come in, at least in IOCP
    we can use several means to expand the state. If we succeeded tag the
    per_io and/or per_socket state with being "outside" of the pool. So on shutdown, graceful close, aborted, etc. We know well, perhaps we need to call free, or whatever, or even closesocket. With IOCP we can create all
    of our sockets up front if we want. The windozer has that fun:

    https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ legacy/ms737757(v=vs.85)

    Shit. That link is not ideal for DisconnectEx. This is direct:

    https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nc-mswsock-lpfn_disconnectex



    It allows a socket to be reused in either AcceptEx or ConnectEx:

    https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nf-mswsock- acceptex

    https://learn.microsoft.com/en-us/windows/win32/api/mswsock/nc-mswsock- lpfn_connectex

    With io_uring, we would want to dedicate the whole box, or a part of it,
    to be okay. This is for IO. Ideally we preallocate as much as the box
    can handle without caking its pants.
    [...]

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Ross Finlayson@3:633/10 to All on Wed Nov 18 16:38:59 2026
    On 11/18/2026 12:40 PM, bartc wrote:
    On 18/11/2026 19:58, Ross Finlayson wrote:

    <More than 3300 lines snipped>

    You're a nutter.


    Hm. Dear me. At that rate I'd soon be a transient if not a criminal.

    Oh well, at least when I'm coding in C/C++ in C and looking for:

    function overloading, including with multiple parameters,
    covariant return-types, and transparent holders,
    polymorphism at run-time, if shallowly,
    and generic and specialized zero-cost container abstractions,
    all with the strong guarantees of types to compile,

    and other sorts features where I'd turn to C++,
    I can less worry my head about picking among
    the ten different ways of doing things in C++
    that were after templates and type_traits.


    "Your time is valuable and your opinion is valued."


    Warm regards



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 07:47:08 2026
    Ross Finlayson pisze:
    On 11/18/2026 12:40 PM, bartc wrote:
    On 18/11/2026 19:58, Ross Finlayson wrote:

    <More than 3300 lines snipped>

    You're a nutter.


    Hm. Dear me. At that rate I'd soon be a transient if not a criminal.

    Oh well, at least when I'm coding in C/C++ in C and looking for:

    function overloading, including with multiple parameters,
    covariant return-types, and transparent holders,
    polymorphism at run-time, if shallowly,
    and generic and specialized zero-cost container abstractions,
    all with the strong guarantees of types to compile,

    and other sorts features where I'd turn to C++,
    I can less worry my head about picking among
    the ten different ways of doing things in C++
    that were after templates and type_traits.


    "Your time is valuable and your opinion is valued."


    Warm regards

    if you want more buzzwords c++ is good way if less stay wit c ;c

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 07:48:07 2026
    fir pisze:
    Ross Finlayson pisze:
    On 11/18/2026 12:40 PM, bartc wrote:
    On 18/11/2026 19:58, Ross Finlayson wrote:

    <More than 3300 lines snipped>

    You're a nutter.


    Hm. Dear me. At that rate I'd soon be a transient if not a criminal.

    Oh well, at least when I'm coding in C/C++ in C and looking for:

    function overloading, including with multiple parameters,
    covariant return-types, and transparent holders,
    polymorphism at run-time, if shallowly,
    and generic and specialized zero-cost container abstractions,
    all with the strong guarantees of types to compile,

    and other sorts features where I'd turn to C++,
    I can less worry my head about picking among
    the ten different ways of doing things in C++
    that were after templates and type_traits.


    "Your time is valuable and your opinion is valued."


    Warm regards





    if you want more buzzwords c++ is good way if less stay wit c ;c


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Nov 19 07:57:54 2026
    Am 19.11.2026 um 07:48 schrieb fir:

    ˙if you want more buzzwords c++ is good way if less stay wit c ;c
    You don't understand C++.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 08:54:56 2026
    Bonita Montero pisze:
    Am 19.11.2026 um 07:48 schrieb fir:

    ˙˙if you want more buzzwords c++ is good way if less stay wit c ;c
    You don't understand C++.


    but i understand shit in c++ lame bonita..it is enough


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Nov 19 09:44:02 2026
    Am 19.11.2026 um 08:54 schrieb fir:

    but i understand shit in c++ lame bonita..it is enough
    The abstraction in C++ maps to very efficient and easy to
    understand parts in the back. But the C-minimalists are too
    stupid to handle that.
    There are no complex data structures in C and it's very hard
    to handle them as easy and as efficient as in C++. Imagine
    you have a unordered_map<string_view, intin C++ and now you
    should implement that in C. With C++ that's a one-liner, with
    C that's a week of work.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 10:13:34 2026
    Bonita Montero pisze:
    Am 19.11.2026 um 08:54 schrieb fir:

    but i understand shit in c++ lame bonita..it is enough
    The abstraction in C++ maps to very efficient and easy to
    understand parts in the back. But the C-minimalists are too
    stupid to handle that.
    There are no complex data structures in C and it's very hard
    to handle them as easy and as efficient as in C++. Imagine
    you have a unordered_map<string_view, intin C++ and now you
    should implement that in C. With C++ that's a one-liner, with
    C that's a week of work.

    youre so lame you dont understand what you talking - youre comparing implementating a library in c to implementating in in c++
    or youre comparing caling one in c to one in c++?

    i guess youre so lame you do the cros comparison here..and on this level
    of iq i dont talk

    overally teh implementation of containers in c its not so hard as you think..how many you impolemented? i m afraid youre so lame you
    implemented none.

    youre so good in containers as in sorting i guess

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 10:15:12 2026
    fir pisze:
    Bonita Montero pisze:
    Am 19.11.2026 um 08:54 schrieb fir:

    but i understand shit in c++ lame bonita..it is enough
    The abstraction in C++ maps to very efficient and easy to
    understand parts in the back. But the C-minimalists are too
    stupid to handle that.
    There are no complex data structures in C and it's very hard
    to handle them as easy and as efficient as in C++. Imagine
    you have a unordered_map<string_view, intin C++ and now you
    should implement that in C. With C++ that's a one-liner, with
    C that's a week of work.

    youre so lame you dont understand what you talking - youre comparing implementating a library in c to implementating in in c++
    or youre comparing caling one in c to one in c++?

    i guess youre so lame you do the cros comparison here..and on this level
    of iq i dont talk

    overally teh implementation of containers in c its not so hard as you think..how many you impolemented? i m afraid youre so lame you
    implemented none.

    youre so good in containers as in sorting i guess

    overally your troll style of talking (oneliners + some bulshit) is not standable imo at all

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 10:18:03 2026
    note this your lame style of talking is so called "dwelling in bulshit"
    and this is below the typical level of this group when people try not to
    do that.. youre and your talk are more like unfamous rick hodgin here unfortunatelly

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 10:30:02 2026
    Bonita Montero pisze:
    There are no complex data structures in C and it's very hard
    to handle them as easy and as efficient as in C++. Imagine
    you have a unordered_map<string_view, intin C++ and now you
    should implement that in C. With C++ that's a one-liner, with
    C that's a week of work.


    as this shot above you get it from ai - i never needed that so i dont
    want to discus it (have may ovn more algebraic attitude to containers)

    writing it alosne is not a weeks of work arso adjusting it to some
    needs not so hard

    this one cosed me like 2 * 3 seconds maybe here

    ofc c has some unconvenience in syntax and with some additions the
    containers in c could be more nice ofc (thats what im sometimes working on)


    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>

    typedef struct {
    const char *ptr;
    int length;
    } StringView;

    typedef struct {
    StringView key;
    int value;
    unsigned hash;
    int used;
    } StringIntMapEntry;

    typedef struct {
    StringIntMapEntry *data;
    int size;
    int capacity;
    } StringIntMap;

    unsigned HashStringView(StringView s)
    {
    unsigned h=2166136261u;
    int i;
    for(i=0;i<s.length;i++) {
    h^=(unsigned char)s.ptr[i];
    h*=16777619u;
    }
    return h;
    }

    int StringViewEqual(StringView a,StringView b)
    {
    return a.length==b.length && memcmp(a.ptr,b.ptr,a.length)==0;
    }

    void StringIntMapInit(StringIntMap *m,int capacity)
    {
    m->size=0;
    m->capacity=capacity;
    m->data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    }

    void StringIntMapFree(StringIntMap *m)
    {
    free(m->data);
    m->data=NULL;
    m->size=0;
    m->capacity=0;
    }

    void StringIntMapResize(StringIntMap *m,int capacity)
    {
    StringIntMapEntry *old=m->data;
    int old_capacity=m->capacity;
    int i;

    m->data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    m->capacity=capacity;
    m->size=0;

    for(i=0;i<old_capacity;i++) {
    if(old[i].used)
    StringIntMapPut(m,old[i].key,old[i].value);
    }

    free(old);
    }

    void StringIntMapPut(StringIntMap *m,StringView key,int value)
    {
    unsigned hash=HashStringView(key);
    int index;

    if((m->size+1)*100>m->capacity*70)
    StringIntMapResize(m,m->capacity*2);

    index=hash%m->capacity;

    while(m->data[index].used) {
    if(m->data[index].hash==hash && StringViewEqual(m->data[index].key,key)) {
    m->data[index].value=value;
    return;
    }
    index=(index+1)%m->capacity;
    }

    m->data[index].used=1;
    m->data[index].key=key;
    m->data[index].value=value;
    m->data[index].hash=hash;
    m->size++;
    }

    int *StringIntMapGet(StringIntMap *m,StringView key)
    {
    unsigned hash=HashStringView(key);
    int index=hash%m->capacity;

    while(m->data[index].used) {
    if(m->data[index].hash==hash && StringViewEqual(m->data[index].key,key))
    return &m->data[index].value;
    index=(index+1)%m->capacity;
    }

    return NULL;
    }

    int main(void)
    {
    StringIntMap map;
    StringIntMapInit(&map,16);

    StringIntMapPut(&map,(StringView){"ship",4},1);
    StringIntMapPut(&map,(StringView){"miss",4},2);
    StringIntMapPut(&map,(StringView){"bull",4},3);

    int *v=StringIntMapGet(&map,(StringView){"miss",4});

    if(v)
    printf("%d\n",*v);

    StringIntMapFree(&map);
    return 0;
    }

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 10:33:53 2026
    what is really usable in c++ is references and some operator overloading
    (like for vectors) but it noy justifies adding of all other trash this
    new cobol offers ;c
    references are ok, operator overloading probably shuld be done maybe a
    bit better..but overally c has more worse problems like this "not seing definitions down" which s terrible and has terrible consequences

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 10:49:32 2026
    fir pisze:
    what is really usable in c++ is references and some operator overloading (like for vectors) but it noy justifies adding of all other trash this
    new cobol offers ;c
    references are ok, operator overloading probably shuld be done maybe a
    bit better..but overally c has more worse problems like this "not seing definitions down" which s terrible and has terrible consequences

    c maybe dont even need just operator overloading - but not having basic
    */+- for float3-float3 and float-float3 is a shame...

    also i could maybe said what is needed to making impelmentation of
    containers in c much better but right now im not focused on that
    (but maybe some day i will get to it yet)

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 11:01:56 2026
    fir pisze:
    ..but overally c has more worse problems like this "not seing
    definitions down" which s terrible and has terrible consequences

    note if not that shit the declarations/externs in c would not be just
    existing (!)

    you could compile each file to .o with no adding one..and compiler could eventually generate some .h as an interface but it would be generated automaticaaly you would not write it

    and that mes with declarations/externs is in fact imo the worst
    practical problem of c today

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Nov 19 14:06:57 2026
    Am 19.11.2026 um 10:13 schrieb fir:

    youre so lame you dont understand what you talking - youre comparing implementating a library in c to implementating in in c++
    or youre comparing caling one in c to one in c++?

    Study C++ containers like unorderdered_map<>, then you may understand
    what I mean.

    overally teh implementation of containers in c its not so hard as you think.. ...
    Look at the count of methods in unordered_map<>:
    https://en.cppreference.com/cpp/container/unordered_map
    Do you think you could implement that so easy ?
    With C++ it's a one-liner to specialize this generic class to
    a user-defined key- / value-pair. With C it's a week's work;
    or you do it the poor stype with callbacks like with qsort().
    And we've seen the performance difference between qsort() and
    std::sport - factor six.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Nov 19 15:53:38 2026
    Am 19.11.2026 um 10:30 schrieb fir:
    Bonita Montero pisze:
    There are no complex data structures in C and it's very hard
    to handle them as easy and as efficient as in C++. Imagine
    you have a unordered_map<string_view, intin C++ and now you
    should implement that in C. With C++ that's a one-liner, with
    C that's a week of work.


    as this shot above you get it from ai - i never needed that so i dont
    want to discus it (have may ovn more algebraic attitude to containers)

    writing it alosne is not a weeks of work arso adjusting it to some
    needs not so hard

    this one cosed me like 2 * 3 seconds maybe here

    ofc c has some unconvenience in syntax and with some additions the containers in c could be more nice ofc (thats what im sometimes working on)


    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>

    typedef struct {
    ˙˙˙ const char *ptr;
    ˙˙˙ int length;
    } StringView;

    typedef struct {
    ˙˙˙ StringView key;
    ˙˙˙ int value;
    ˙˙˙ unsigned hash;
    ˙˙˙ int used;
    } StringIntMapEntry;

    typedef struct {
    ˙˙˙ StringIntMapEntry *data;
    ˙˙˙ int size;
    ˙˙˙ int capacity;
    } StringIntMap;

    unsigned HashStringView(StringView s)
    {
    ˙˙˙ unsigned h=2166136261u;
    ˙˙˙ int i;
    ˙˙˙ for(i=0;i<s.length;i++) {
    ˙˙˙˙˙˙˙ h^=(unsigned char)s.ptr[i];
    ˙˙˙˙˙˙˙ h*=16777619u;
    ˙˙˙ }
    ˙˙˙ return h;
    }

    int StringViewEqual(StringView a,StringView b)
    {
    ˙˙˙ return a.length==b.length && memcmp(a.ptr,b.ptr,a.length)==0;
    }

    void StringIntMapInit(StringIntMap *m,int capacity)
    {
    ˙˙˙ m->size=0;
    ˙˙˙ m->capacity=capacity;
    ˙˙˙ m-
    data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    }

    void StringIntMapFree(StringIntMap *m)
    {
    ˙˙˙ free(m->data);
    ˙˙˙ m->data=NULL;
    ˙˙˙ m->size=0;
    ˙˙˙ m->capacity=0;
    }

    void StringIntMapResize(StringIntMap *m,int capacity)
    {
    ˙˙˙ StringIntMapEntry *old=m->data;
    ˙˙˙ int old_capacity=m->capacity;
    ˙˙˙ int i;

    ˙˙˙ m-
    data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    ˙˙˙ m->capacity=capacity;
    ˙˙˙ m->size=0;

    ˙˙˙ for(i=0;i<old_capacity;i++) {
    ˙˙˙˙˙˙˙ if(old[i].used)
    ˙˙˙˙˙˙˙˙˙˙˙ StringIntMapPut(m,old[i].key,old[i].value);
    ˙˙˙ }

    ˙˙˙ free(old);
    }

    void StringIntMapPut(StringIntMap *m,StringView key,int value)
    {
    ˙˙˙ unsigned hash=HashStringView(key);
    ˙˙˙ int index;

    ˙˙˙ if((m->size+1)*100>m->capacity*70)
    ˙˙˙˙˙˙˙ StringIntMapResize(m,m->capacity*2);

    ˙˙˙ index=hash%m->capacity;

    ˙˙˙ while(m->data[index].used) {
    ˙˙˙˙˙˙˙ if(m->data[index].hash==hash && StringViewEqual(m-
    data[index].key,key)) {
    ˙˙˙˙˙˙˙˙˙˙˙ m->data[index].value=value;
    ˙˙˙˙˙˙˙˙˙˙˙ return;
    ˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙ index=(index+1)%m->capacity;
    ˙˙˙ }

    ˙˙˙ m->data[index].used=1;
    ˙˙˙ m->data[index].key=key;
    ˙˙˙ m->data[index].value=value;
    ˙˙˙ m->data[index].hash=hash;
    ˙˙˙ m->size++;
    }

    int *StringIntMapGet(StringIntMap *m,StringView key)
    {
    ˙˙˙ unsigned hash=HashStringView(key);
    ˙˙˙ int index=hash%m->capacity;

    ˙˙˙ while(m->data[index].used) {
    ˙˙˙˙˙˙˙ if(m->data[index].hash==hash && StringViewEqual(m-
    data[index].key,key))
    ˙˙˙˙˙˙˙˙˙˙˙ return &m->data[index].value;
    ˙˙˙˙˙˙˙ index=(index+1)%m->capacity;
    ˙˙˙ }

    ˙˙˙ return NULL;
    }
    Try to implement that with the full functionality of std::unordered_map.
    You suck.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bonita Montero@3:633/10 to All on Thu Nov 19 15:54:08 2026
    Am 19.11.2026 um 10:33 schrieb fir:

    what is really usable in c++ is references and some operator overloading (like for vectors) ...
    You don't understand the rest.


    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu Nov 19 16:03:42 2026
    Bonita Montero pisze:
    Am 19.11.2026 um 10:30 schrieb fir:
    Bonita Montero pisze:
    There are no complex data structures in C and it's very hard
    to handle them as easy and as efficient as in C++. Imagine
    you have a unordered_map<string_view, intin C++ and now you
    should implement that in C. With C++ that's a one-liner, with
    C that's a week of work.


    as this shot above you get it from ai - i never needed that so i dont
    want to discus it (have may ovn more algebraic attitude to containers)

    writing it alosne is not a weeks of work arso adjusting it to some
    needs not so hard

    this one cosed me like 2 * 3 seconds maybe here

    ofc c has some unconvenience in syntax and with some additions the
    containers in c could be more nice ofc (thats what im sometimes
    working on)


    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>

    typedef struct {
    ˙˙˙˙ const char *ptr;
    ˙˙˙˙ int length;
    } StringView;

    typedef struct {
    ˙˙˙˙ StringView key;
    ˙˙˙˙ int value;
    ˙˙˙˙ unsigned hash;
    ˙˙˙˙ int used;
    } StringIntMapEntry;

    typedef struct {
    ˙˙˙˙ StringIntMapEntry *data;
    ˙˙˙˙ int size;
    ˙˙˙˙ int capacity;
    } StringIntMap;

    unsigned HashStringView(StringView s)
    {
    ˙˙˙˙ unsigned h=2166136261u;
    ˙˙˙˙ int i;
    ˙˙˙˙ for(i=0;i<s.length;i++) {
    ˙˙˙˙˙˙˙˙ h^=(unsigned char)s.ptr[i];
    ˙˙˙˙˙˙˙˙ h*=16777619u;
    ˙˙˙˙ }
    ˙˙˙˙ return h;
    }

    int StringViewEqual(StringView a,StringView b)
    {
    ˙˙˙˙ return a.length==b.length && memcmp(a.ptr,b.ptr,a.length)==0;
    }

    void StringIntMapInit(StringIntMap *m,int capacity)
    {
    ˙˙˙˙ m->size=0;
    ˙˙˙˙ m->capacity=capacity;
    ˙˙˙˙ m-
    data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    }

    void StringIntMapFree(StringIntMap *m)
    {
    ˙˙˙˙ free(m->data);
    ˙˙˙˙ m->data=NULL;
    ˙˙˙˙ m->size=0;
    ˙˙˙˙ m->capacity=0;
    }

    void StringIntMapResize(StringIntMap *m,int capacity)
    {
    ˙˙˙˙ StringIntMapEntry *old=m->data;
    ˙˙˙˙ int old_capacity=m->capacity;
    ˙˙˙˙ int i;

    ˙˙˙˙ m-
    data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    ˙˙˙˙ m->capacity=capacity;
    ˙˙˙˙ m->size=0;

    ˙˙˙˙ for(i=0;i<old_capacity;i++) {
    ˙˙˙˙˙˙˙˙ if(old[i].used)
    ˙˙˙˙˙˙˙˙˙˙˙˙ StringIntMapPut(m,old[i].key,old[i].value);
    ˙˙˙˙ }

    ˙˙˙˙ free(old);
    }

    void StringIntMapPut(StringIntMap *m,StringView key,int value)
    {
    ˙˙˙˙ unsigned hash=HashStringView(key);
    ˙˙˙˙ int index;

    ˙˙˙˙ if((m->size+1)*100>m->capacity*70)
    ˙˙˙˙˙˙˙˙ StringIntMapResize(m,m->capacity*2);

    ˙˙˙˙ index=hash%m->capacity;

    ˙˙˙˙ while(m->data[index].used) {
    ˙˙˙˙˙˙˙˙ if(m->data[index].hash==hash && StringViewEqual(m-
    data[index].key,key)) {
    ˙˙˙˙˙˙˙˙˙˙˙˙ m->data[index].value=value;
    ˙˙˙˙˙˙˙˙˙˙˙˙ return;
    ˙˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙˙ index=(index+1)%m->capacity;
    ˙˙˙˙ }

    ˙˙˙˙ m->data[index].used=1;
    ˙˙˙˙ m->data[index].key=key;
    ˙˙˙˙ m->data[index].value=value;
    ˙˙˙˙ m->data[index].hash=hash;
    ˙˙˙˙ m->size++;
    }

    int *StringIntMapGet(StringIntMap *m,StringView key)
    {
    ˙˙˙˙ unsigned hash=HashStringView(key);
    ˙˙˙˙ int index=hash%m->capacity;

    ˙˙˙˙ while(m->data[index].used) {
    ˙˙˙˙˙˙˙˙ if(m->data[index].hash==hash && StringViewEqual(m-
    data[index].key,key))
    ˙˙˙˙˙˙˙˙˙˙˙˙ return &m->data[index].value;
    ˙˙˙˙˙˙˙˙ index=(index+1)%m->capacity;
    ˙˙˙˙ }

    ˙˙˙˙ return NULL;
    }
    Try to implement that with the full functionality of std::unordered_map.
    You suck.

    primitive troll lame bonita told me i suck..i think we ended all
    possible conversation as your level of posting is near animal imo...
    so good luck ..in your animal level world

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Thu Nov 19 12:40:07 2026
    On 11/19/2026 6:53 AM, Bonita Montero wrote:
    Am 19.11.2026 um 10:30 schrieb fir:
    Bonita Montero pisze:
    There are no complex data structures in C and it's very hard
    to handle them as easy and as efficient as in C++. Imagine
    you have a unordered_map<string_view, intin C++ and now you
    should implement that in C. With C++ that's a one-liner, with
    C that's a week of work.


    as this shot above you get it from ai - i never needed that so i dont
    want to discus it (have may ovn more algebraic attitude to containers)

    writing it alosne is not a weeks of work arso adjusting it to some
    needs not so hard

    this one cosed me like 2 * 3 seconds maybe here

    ofc c has some unconvenience in syntax and with some additions the
    containers in c could be more nice ofc (thats what im sometimes
    working on)


    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>

    typedef struct {
    ˙˙˙˙ const char *ptr;
    ˙˙˙˙ int length;
    } StringView;

    typedef struct {
    ˙˙˙˙ StringView key;
    ˙˙˙˙ int value;
    ˙˙˙˙ unsigned hash;
    ˙˙˙˙ int used;
    } StringIntMapEntry;

    typedef struct {
    ˙˙˙˙ StringIntMapEntry *data;
    ˙˙˙˙ int size;
    ˙˙˙˙ int capacity;
    } StringIntMap;

    unsigned HashStringView(StringView s)
    {
    ˙˙˙˙ unsigned h=2166136261u;
    ˙˙˙˙ int i;
    ˙˙˙˙ for(i=0;i<s.length;i++) {
    ˙˙˙˙˙˙˙˙ h^=(unsigned char)s.ptr[i];
    ˙˙˙˙˙˙˙˙ h*=16777619u;
    ˙˙˙˙ }
    ˙˙˙˙ return h;
    }

    int StringViewEqual(StringView a,StringView b)
    {
    ˙˙˙˙ return a.length==b.length && memcmp(a.ptr,b.ptr,a.length)==0;
    }

    void StringIntMapInit(StringIntMap *m,int capacity)
    {
    ˙˙˙˙ m->size=0;
    ˙˙˙˙ m->capacity=capacity;
    ˙˙˙˙ m-
    data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    }

    void StringIntMapFree(StringIntMap *m)
    {
    ˙˙˙˙ free(m->data);
    ˙˙˙˙ m->data=NULL;
    ˙˙˙˙ m->size=0;
    ˙˙˙˙ m->capacity=0;
    }

    void StringIntMapResize(StringIntMap *m,int capacity)
    {
    ˙˙˙˙ StringIntMapEntry *old=m->data;
    ˙˙˙˙ int old_capacity=m->capacity;
    ˙˙˙˙ int i;

    ˙˙˙˙ m-
    data=(StringIntMapEntry*)calloc(capacity,sizeof(StringIntMapEntry));
    ˙˙˙˙ m->capacity=capacity;
    ˙˙˙˙ m->size=0;

    ˙˙˙˙ for(i=0;i<old_capacity;i++) {
    ˙˙˙˙˙˙˙˙ if(old[i].used)
    ˙˙˙˙˙˙˙˙˙˙˙˙ StringIntMapPut(m,old[i].key,old[i].value);
    ˙˙˙˙ }

    ˙˙˙˙ free(old);
    }

    void StringIntMapPut(StringIntMap *m,StringView key,int value)
    {
    ˙˙˙˙ unsigned hash=HashStringView(key);
    ˙˙˙˙ int index;

    ˙˙˙˙ if((m->size+1)*100>m->capacity*70)
    ˙˙˙˙˙˙˙˙ StringIntMapResize(m,m->capacity*2);

    ˙˙˙˙ index=hash%m->capacity;

    ˙˙˙˙ while(m->data[index].used) {
    ˙˙˙˙˙˙˙˙ if(m->data[index].hash==hash && StringViewEqual(m-
    data[index].key,key)) {
    ˙˙˙˙˙˙˙˙˙˙˙˙ m->data[index].value=value;
    ˙˙˙˙˙˙˙˙˙˙˙˙ return;
    ˙˙˙˙˙˙˙˙ }
    ˙˙˙˙˙˙˙˙ index=(index+1)%m->capacity;
    ˙˙˙˙ }

    ˙˙˙˙ m->data[index].used=1;
    ˙˙˙˙ m->data[index].key=key;
    ˙˙˙˙ m->data[index].value=value;
    ˙˙˙˙ m->data[index].hash=hash;
    ˙˙˙˙ m->size++;
    }

    int *StringIntMapGet(StringIntMap *m,StringView key)
    {
    ˙˙˙˙ unsigned hash=HashStringView(key);
    ˙˙˙˙ int index=hash%m->capacity;

    ˙˙˙˙ while(m->data[index].used) {
    ˙˙˙˙˙˙˙˙ if(m->data[index].hash==hash && StringViewEqual(m-
    data[index].key,key))
    ˙˙˙˙˙˙˙˙˙˙˙˙ return &m->data[index].value;
    ˙˙˙˙˙˙˙˙ index=(index+1)%m->capacity;
    ˙˙˙˙ }

    ˙˙˙˙ return NULL;
    }
    Try to implement that with the full functionality of std::unordered_map.
    You suck.


    I am pretty sure AI wrote that code for him anyway.

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)