• Re: C: a question about scope automatics in C

    From Ross Finlayson@3:633/10 to All on Tuesday, November 03, 2026 07:14:57
    On 11/03/2026 02:47 AM, David Brown wrote:
    On 02/11/2026 19:38, Ross Finlayson wrote:

    C: a question about scope automatics in C

    Hello, I hope someone can tell me whether C may make
    for scope automatics any account of attaching side-effects
    to block-declared variables about scope-exit of automatics
    making for any way in C to attach behavior to scope-exit,
    or any way to make for when a variable goes out of scope
    (block-scope, or, function-scope) to make any account of
    cleanup of it. C++ of course has that's the usual way of
    things with stack-allocation and block-scope for automatics,
    I'm wondering if there's any way C makes it so (I think not,
    yet would be glad to know so).


    If not, are there common compiler extensions to so indicate
    when a variable goes out of scope and make effects on it?

    Thanks for reading, also I'd be interested your opinion.


    As has been pointed out by several people, if you want helpful answers,
    you will have to make a lot more effort to write clear, grammatical
    English. Most of what you write is barely comprehensible. Try thinking before you write, split text into sentences and paragraphs, and then
    re-read what you have written. Maybe it would help if you give some
    examples in C.

    It would also be useful if you tried to stay up to date with modern C standards, but of course it is fine to ask about the details. Most C programmers don't read the standards or proposals, but there is no point
    in trying to invent "new" features if they are already in the language,
    or likely to come in the near future.

    And please do not post extracts from some AI chatbot. If you want to
    use these tools as a source of information, that's up to you - they can
    be useful research assistants, but are often inaccurate. (I only read a little of your "GG" post, and there was a lot wrong in it.) People in a group like comp.lang.c are here to talk with, listen to, learn from and
    help other people. If we want AI slop, we know where to find it ourselves.


    As to the particular matter in hand - running some sort of clean-up code
    when a local variable's lifetime ends - you should first understand that
    it is the variable's /lifetime/ that is important, not its scope. For
    local variables that are not declared "static", these are closely
    related. But "scope" is about when the identifier's name can be used, "lifetime" is when the object itself exists.

    For gcc (and clang, and perhaps other compilers), you can use the
    "cleanup" attribute to run code at the end of the lifetime of an
    automatic storage duration variable. (The gcc documentation incorrectly
    says "scope", and gives no information about complicated situations such
    as using "goto" or "longjmp".)

    <https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-cleanup>


    For the future, it is likely that C will gain a "defer" feature in the
    next C standard (currently known as C2y). Macros to get an approximate version of this are available, using gcc extensions. Here is a simple
    one :

    <https://antonz.org/defer-in-c/>

    More advanced versions can be found on Jens Gustedt's blog :

    <https://gustedt.wordpress.com/2025/01/06/simple-defer-ready-to-use/> <https://gustedt.wordpress.com/2026/02/15/defer-available-in-gcc-and-clang/>





    It's appreciated about "cleanup" and "defer" as
    with regards to instrumenting code at entry and exit,
    of function-scope and block-scope.

    Hm. Maybe a story will help. (Maybe it won't.)

    So, let's say we've all been around programming
    since at least three decades ago, and we're all
    pretty familiar with C and POSIX, and about machine
    architecture, and about the usual ways operating systems
    make for the execution the process model, and about
    the model of memory.


    So, a most familiar sort of thing in C is malloc & free,
    vis-a-vis, local variables, which are automatic or auto
    in storage-class, about the lifetime of objects according
    to their types and storage-class.

    Then, about temporaries, here local variables that are
    just declared then initialized as defined to bridge the
    gap between a value (or, structure, i.e., struct or array)
    of one type and value (or structure) of another type,
    if they're structures and not to be particularly large,
    so that the code-segment isn't particularly large,
    and to be re-entrant, so not in the data-segment,
    then a usual idea is to allocate them dynamically,
    eg with malloc & free, memory-allocating buffers
    before use and free'ing them after use.

    So, malloc and free are system-calls, in the implementation
    or the runtime or the O.S., and so when the structure is
    already in the code or data-segment, and needn't be
    re-entrant, then these system-calls can be reduced.


    There's a usual idea that the code that's:

    alias-less
    branch-less
    stall-less
    call-less
    fault-less

    has that each these alias/branch/stall/call/fault
    in the processor: get in the way of the straight-line
    sort of full pipeline of the processor.

    So, avoiding system-calls, when it's possible,
    i.e. that it remains correct, may make for
    improved performance, about things like:

    correctness
    performance
    diagnosibility
    maintainability
    robustness

    and so on, tthe runtime side of "quality".



    So, one account of correctness, is error-handling or
    exception-handling, and, another is "failure modes".
    A usual idea in distributed is that failure modes
    have that the robustness of the program besides
    the algorithm, is mostly that people design programs
    that failures are fatal and the programs just exit,
    vis-a-vis the algorithm and the data at rest, or
    for "no drops & no dupes", and the "eventually consistent"
    and "self-healing", ideas from distributed systems. So,
    I'm mentioning this, because my goal is robust programs
    besides, because eventually someone's going to want
    a program that if they send it a signal that it doesn't
    just die, and that a signal could arrive at an inopportune
    time, that basically "cleanup" and "defer", for example,
    would never be invoked, then if it was in the condition
    where memory was malloc'ed and not free'd, that would
    be a leak, which, over time, would equal waste and perhaps
    also failure.

    So, I want the flexibility and efficiency of "dynamic allocation",
    so, not a waste of the space in the code-segment or data-segment,
    which might not be re-entrant anyways, and the robustness for
    correctness of cleanup or as after stack-unwinding. Then, where
    that's at already is in the stack-segment, since according to the
    process-model and thusly also of threads these implementers
    of runtimes, the stack-segment or thread-stack-segment is
    a small, fixed amount of memory that may be divvied up by
    the process itself for its own purposes as a model of dynamic
    allocation: with the property that if the function exits, like
    if a signal arrives: it's the only thing the operating system can
    give to prevent leaks of otherwise "dynamically" allocated data,
    without the usual failure mode of the fatal error and killing
    the entire process and reclaiming all its resources.


    Then, there are some more needful's of the sources.

    portable
    re-usable
    un-cluttered
    idiomatic, not necessarily yet usually
    "clean", though clutter as attribution vis-a-vis "fighting the interface"

    As well, there are needful's of the libraries, or re-usable code.
    These are usually enough matters of "library design" with
    regards to principle-of-least-atonishment usually enough
    and "3'rd party code" and "dependency management",
    about "DLL Hell" and "Jar Hell" and the like, yet mostly about
    the process model and the resource model and again part of "quality".




    So, when dealing with dynamic allocations, there are variously
    long-lived or short-lived allocations, and, variously, of fixed-size
    or variable-size, or length.


    Then, these "automatic temporary arrays", are short-lived, vis-a-vis,
    "buffers" usually enough more generally, which may be the destinations
    of other process' lifecycles in the O.S. I/O, the operating-system's
    account of input/output.


    So, I figure anybody who bothers reading this "knows" all these
    things, and they're not even un-usual, in usual sorts of accounts
    of the thorough.




    Then, about the "A.I. chat-bot output and shove off with that",
    that's agreeable, myself I type about sixty words per minute
    yet read about a million miles per hour, and I'll read it critically
    anyways, then that sort of thing is take-it-or-leave-it.


    So, basically since "C" doesn't say otherwise, about the lifeycle
    and duration of object storage, then it's figured that a "least-ledge
    automatic temporary arrays", can do some work before the compiler
    starts after it parses the compilation units, and figure that these "least-ledge automatic temporary arrays", can live in a very brief
    form in the stack-segment, while the source code looks un-cluttered,
    for example to make non-re-entrant code into re-entrant code for
    the multi-threaded server applications, without changing the code
    (where it fits).




    --- 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 Tuesday, November 03, 2026 17:08:23
    On 03/11/2026 16:14, Ross Finlayson wrote:
    On 11/03/2026 02:47 AM, David Brown wrote:
    On 02/11/2026 19:38, Ross Finlayson wrote:

    C: a question about scope automatics in C

    Hello, I hope someone can tell me whether C may make
    for scope automatics any account of attaching side-effects
    to block-declared variables about scope-exit of automatics
    making for any way in C to attach behavior to scope-exit,
    or any way to make for when a variable goes out of scope
    (block-scope, or, function-scope) to make any account of
    cleanup of it. C++ of course has that's the usual way of
    things with stack-allocation and block-scope for automatics,
    I'm wondering if there's any way C makes it so (I think not,
    yet would be glad to know so).


    If not, are there common compiler extensions to so indicate
    when a variable goes out of scope and make effects on it?

    Thanks for reading, also I'd be interested your opinion.


    As has been pointed out by several people, if you want helpful answers,
    you will have to make a lot more effort to write clear, grammatical
    English.ÿ Most of what you write is barely comprehensible.ÿ Try thinking
    before you write, split text into sentences and paragraphs, and then
    re-read what you have written.ÿ Maybe it would help if you give some
    examples in C.

    It would also be useful if you tried to stay up to date with modern C
    standards, but of course it is fine to ask about the details.ÿ Most C
    programmers don't read the standards or proposals, but there is no point
    in trying to invent "new" features if they are already in the language,
    or likely to come in the near future.

    And please do not post extracts from some AI chatbot.ÿ If you want to
    use these tools as a source of information, that's up to you - they can
    be useful research assistants, but are often inaccurate.ÿ (I only read a
    little of your "GG" post, and there was a lot wrong in it.)ÿ People in a
    group like comp.lang.c are here to talk with, listen to, learn from and
    help other people.ÿ If we want AI slop, we know where to find it
    ourselves.


    As to the particular matter in hand - running some sort of clean-up code
    when a local variable's lifetime ends - you should first understand that
    it is the variable's /lifetime/ that is important, not its scope.ÿ For
    local variables that are not declared "static", these are closely
    related.ÿ But "scope" is about when the identifier's name can be used,
    "lifetime" is when the object itself exists.

    For gcc (and clang, and perhaps other compilers), you can use the
    "cleanup" attribute to run code at the end of the lifetime of an
    automatic storage duration variable.ÿ (The gcc documentation incorrectly
    says "scope", and gives no information about complicated situations such
    as using "goto" or "longjmp".)

    <https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-cleanup>


    For the future, it is likely that C will gain a "defer" feature in the
    next C standard (currently known as C2y).ÿ Macros to get an approximate
    version of this are available, using gcc extensions.ÿ Here is a simple
    one :

    <https://antonz.org/defer-in-c/>

    More advanced versions can be found on Jens Gustedt's blog :

    <https://gustedt.wordpress.com/2025/01/06/simple-defer-ready-to-use/>
    <https://gustedt.wordpress.com/2026/02/15/defer-available-in-gcc-and-
    clang/>





    It's appreciated about "cleanup" and "defer" as
    with regards to instrumenting code at entry and exit,
    of function-scope and block-scope.

    Hm. Maybe a story will help. (Maybe it won't.)

    It didn't help. Your writing is absolute tripe. I have no idea what
    you are trying to say, or what you are trying to ask - I can't even tell
    if you are actually asking anything.

    If the information about gcc's "cleanup" attribute and the macros and
    C2y "defer" proposal helps you, that's great.

    But if you can't write understandable text, there is no point in
    discussing further.

    Writing sixty words per minute is useless when the words don't convey information. Reading "a million miles per hour" is useless when you do
    not take in the content of what you are reading.


    --- 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 Tuesday, November 03, 2026 08:16:16
    On 11/03/2026 08:08 AM, David Brown wrote:
    On 03/11/2026 16:14, Ross Finlayson wrote:
    On 11/03/2026 02:47 AM, David Brown wrote:
    On 02/11/2026 19:38, Ross Finlayson wrote:

    C: a question about scope automatics in C

    Hello, I hope someone can tell me whether C may make
    for scope automatics any account of attaching side-effects
    to block-declared variables about scope-exit of automatics
    making for any way in C to attach behavior to scope-exit,
    or any way to make for when a variable goes out of scope
    (block-scope, or, function-scope) to make any account of
    cleanup of it. C++ of course has that's the usual way of
    things with stack-allocation and block-scope for automatics,
    I'm wondering if there's any way C makes it so (I think not,
    yet would be glad to know so).


    If not, are there common compiler extensions to so indicate
    when a variable goes out of scope and make effects on it?

    Thanks for reading, also I'd be interested your opinion.


    As has been pointed out by several people, if you want helpful answers,
    you will have to make a lot more effort to write clear, grammatical
    English. Most of what you write is barely comprehensible. Try thinking >>> before you write, split text into sentences and paragraphs, and then
    re-read what you have written. Maybe it would help if you give some
    examples in C.

    It would also be useful if you tried to stay up to date with modern C
    standards, but of course it is fine to ask about the details. Most C
    programmers don't read the standards or proposals, but there is no point >>> in trying to invent "new" features if they are already in the language,
    or likely to come in the near future.

    And please do not post extracts from some AI chatbot. If you want to
    use these tools as a source of information, that's up to you - they can
    be useful research assistants, but are often inaccurate. (I only read a >>> little of your "GG" post, and there was a lot wrong in it.) People in a >>> group like comp.lang.c are here to talk with, listen to, learn from and
    help other people. If we want AI slop, we know where to find it
    ourselves.


    As to the particular matter in hand - running some sort of clean-up code >>> when a local variable's lifetime ends - you should first understand that >>> it is the variable's /lifetime/ that is important, not its scope. For
    local variables that are not declared "static", these are closely
    related. But "scope" is about when the identifier's name can be used,
    "lifetime" is when the object itself exists.

    For gcc (and clang, and perhaps other compilers), you can use the
    "cleanup" attribute to run code at the end of the lifetime of an
    automatic storage duration variable. (The gcc documentation incorrectly >>> says "scope", and gives no information about complicated situations such >>> as using "goto" or "longjmp".)

    <https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-cleanup> >>>


    For the future, it is likely that C will gain a "defer" feature in the
    next C standard (currently known as C2y). Macros to get an approximate
    version of this are available, using gcc extensions. Here is a simple
    one :

    <https://antonz.org/defer-in-c/>

    More advanced versions can be found on Jens Gustedt's blog :

    <https://gustedt.wordpress.com/2025/01/06/simple-defer-ready-to-use/>
    <https://gustedt.wordpress.com/2026/02/15/defer-available-in-gcc-and-
    clang/>





    It's appreciated about "cleanup" and "defer" as
    with regards to instrumenting code at entry and exit,
    of function-scope and block-scope.

    Hm. Maybe a story will help. (Maybe it won't.)

    It didn't help. Your writing is absolute tripe. I have no idea what
    you are trying to say, or what you are trying to ask - I can't even tell
    if you are actually asking anything.

    If the information about gcc's "cleanup" attribute and the macros and
    C2y "defer" proposal helps you, that's great.

    But if you can't write understandable text, there is no point in
    discussing further.

    Writing sixty words per minute is useless when the words don't convey information. Reading "a million miles per hour" is useless when you do
    not take in the content of what you are reading.



    Hm. "Computronomat: natural language understanding, computational
    linguistic comprehension", is a video essay or lecture recorded the
    other day, I suppose that sounds like non-sense, also.


    I'm not trying to cause trouble - just pointing out an opportunity
    to make for a convention (code-convention and calling-convention and compiler-convention and idiom and thei discipline), so that these
    sorts "automatic temporary arrays", when they fit, can be accessed
    as restrict'ed pointers allocated (according to the implementation,
    according to the specification, so pretty much according to alloca()
    on the implementation, standard language specification guardians),
    a "perceived requirement" as with regards to "perceived deficiencies",
    about high-performance high-reliability systems code.

    Does that make sense so far, yet?



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From bartc@3:633/10 to All on Tuesday, November 03, 2026 16:28:06
    On 03/11/2026 16:16, Ross Finlayson wrote:

    Hm. "Computronomat: natural language understanding, computational
    linguistic comprehension", is a video essay or lecture recorded the
    other day, I suppose that sounds like non-sense, also.


    I'm not trying to cause trouble - just pointing out an opportunity
    to make for a convention (code-convention and calling-convention and compiler-convention and idiom and thei discipline), so that these
    sorts "automatic temporary arrays", when they fit, can be accessed
    as restrict'ed pointers allocated (according to the implementation,
    according to the specification, so pretty much according to alloca()
    on the implementation, standard language specification guardians),
    a "perceived requirement" as with regards to "perceived deficiencies",
    about high-performance high-reliability systems code.

    Does that make sense so far, yet?

    No. You sound just like a badly programmed bot.




    --- 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 Tuesday, November 03, 2026 17:47:26
    On 03/11/2026 17:16, Ross Finlayson wrote:
    On 11/03/2026 08:08 AM, David Brown wrote:
    On 03/11/2026 16:14, Ross Finlayson wrote:
    On 11/03/2026 02:47 AM, David Brown wrote:
    On 02/11/2026 19:38, Ross Finlayson wrote:

    C: a question about scope automatics in C

    Hello, I hope someone can tell me whether C may make
    for scope automatics any account of attaching side-effects
    to block-declared variables about scope-exit of automatics
    making for any way in C to attach behavior to scope-exit,
    or any way to make for when a variable goes out of scope
    (block-scope, or, function-scope) to make any account of
    cleanup of it. C++ of course has that's the usual way of
    things with stack-allocation and block-scope for automatics,
    I'm wondering if there's any way C makes it so (I think not,
    yet would be glad to know so).


    If not, are there common compiler extensions to so indicate
    when a variable goes out of scope and make effects on it?

    Thanks for reading, also I'd be interested your opinion.


    As has been pointed out by several people, if you want helpful answers, >>>> you will have to make a lot more effort to write clear, grammatical
    English.ÿ Most of what you write is barely comprehensible.ÿ Try
    thinking
    before you write, split text into sentences and paragraphs, and then
    re-read what you have written.ÿ Maybe it would help if you give some
    examples in C.

    It would also be useful if you tried to stay up to date with modern C
    standards, but of course it is fine to ask about the details.ÿ Most C
    programmers don't read the standards or proposals, but there is no
    point
    in trying to invent "new" features if they are already in the language, >>>> or likely to come in the near future.

    And please do not post extracts from some AI chatbot.ÿ If you want to
    use these tools as a source of information, that's up to you - they can >>>> be useful research assistants, but are often inaccurate.ÿ (I only
    read a
    little of your "GG" post, and there was a lot wrong in it.)ÿ People
    in a
    group like comp.lang.c are here to talk with, listen to, learn from and >>>> help other people.ÿ If we want AI slop, we know where to find it
    ourselves.


    As to the particular matter in hand - running some sort of clean-up
    code
    when a local variable's lifetime ends - you should first understand
    that
    it is the variable's /lifetime/ that is important, not its scope.ÿ For >>>> local variables that are not declared "static", these are closely
    related.ÿ But "scope" is about when the identifier's name can be used, >>>> "lifetime" is when the object itself exists.

    For gcc (and clang, and perhaps other compilers), you can use the
    "cleanup" attribute to run code at the end of the lifetime of an
    automatic storage duration variable.ÿ (The gcc documentation
    incorrectly
    says "scope", and gives no information about complicated situations
    such
    as using "goto" or "longjmp".)

    <https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-
    cleanup>



    For the future, it is likely that C will gain a "defer" feature in the >>>> next C standard (currently known as C2y).ÿ Macros to get an approximate >>>> version of this are available, using gcc extensions.ÿ Here is a simple >>>> one :

    <https://antonz.org/defer-in-c/>

    More advanced versions can be found on Jens Gustedt's blog :

    <https://gustedt.wordpress.com/2025/01/06/simple-defer-ready-to-use/>
    <https://gustedt.wordpress.com/2026/02/15/defer-available-in-gcc-and-
    clang/>





    It's appreciated about "cleanup" and "defer" as
    with regards to instrumenting code at entry and exit,
    of function-scope and block-scope.

    Hm. Maybe a story will help. (Maybe it won't.)

    It didn't help.ÿ Your writing is absolute tripe.ÿ I have no idea what
    you are trying to say, or what you are trying to ask - I can't even tell
    if you are actually asking anything.

    If the information about gcc's "cleanup" attribute and the macros and
    C2y "defer" proposal helps you, that's great.

    But if you can't write understandable text, there is no point in
    discussing further.

    Writing sixty words per minute is useless when the words don't convey
    information.ÿ Reading "a million miles per hour" is useless when you do
    not take in the content of what you are reading.



    Hm. "Computronomat: natural language understanding, computational
    linguistic comprehension", is a video essay or lecture recorded the
    other day, I suppose that sounds like non-sense, also.


    I'm not trying to cause trouble - just pointing out an opportunity
    to make for a convention (code-convention and calling-convention and compiler-convention and idiom and thei discipline), so that these
    sorts "automatic temporary arrays", when they fit, can be accessed
    as restrict'ed pointers allocated (according to the implementation,
    according to the specification, so pretty much according to alloca()
    on the implementation, standard language specification guardians),
    a "perceived requirement" as with regards to "perceived deficiencies",
    about high-performance high-reliability systems code.

    Does that make sense so far, yet?

    Sorry, no.

    I realise you are not trying to "cause trouble", just as I am not trying
    to be rude. Again, I would urge you to write short, clear C code to
    express what you are trying to say. Hopefully that will work better
    than when you try to write prose.

    If all you wanted to ask about has already been answered with "cleanup"
    and "defer", then we should leave it at 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 Tuesday, November 03, 2026 09:02:32
    On 11/03/2026 08:28 AM, bartc wrote:
    On 03/11/2026 16:16, Ross Finlayson wrote:

    Hm. "Computronomat: natural language understanding, computational
    linguistic comprehension", is a video essay or lecture recorded the
    other day, I suppose that sounds like non-sense, also.


    I'm not trying to cause trouble - just pointing out an opportunity
    to make for a convention (code-convention and calling-convention and
    compiler-convention and idiom and thei discipline), so that these
    sorts "automatic temporary arrays", when they fit, can be accessed
    as restrict'ed pointers allocated (according to the implementation,
    according to the specification, so pretty much according to alloca()
    on the implementation, standard language specification guardians),
    a "perceived requirement" as with regards to "perceived deficiencies",
    about high-performance high-reliability systems code.

    Does that make sense so far, yet?

    No. You sound just like a badly programmed bot.




    Euh, ....

    So, it doesn't compute? It dasn't?


    So, say you got a long routine and it's a usual account of mapping from
    one data-structure to another and converting or formatting, or, it's an
    account of serialization or deserialization the mapping (usually enough
    it's called), that it's required buffers, which may have fixed-bounds,
    because for example you know that the entire language is words under
    a fixed-bound, and any conversions/formatting also never go beyond the
    bound, like a database-schema enforces it upstream and the character-set-encoding is unambiguous or well-defined, and the
    formatting fits
    within the bounds.


    Then, if one of these records has some dozens, scores, or hundreds of
    fields, among textual, numeric, and calendric built-in and user-defined
    types, then each one of these might need a buffer or buffers the
    scratch-pad or working-memory, as the working-memory of the conversion & formatting routines, since for example strtok and strtok_r and other
    accounts of the conversion & formatting after the accessor/mutator
    routines of the records their fields in accounts of structured
    programming: are always using temporaries, here "automatic temporary
    arrays", their buffers.


    Now, say it only needs one of those buffers, yet, there are the umpteen identifiers each with their declaration about it.

    So, why lose?

    Now, it's simple to just declare a buffer array at the beginning of
    the routine, and re-use it, then for example that the compiler will
    observe the dependency of the list of field-mappings, and be calling
    the conversion & formatting routines, that then the compiler is quite
    free to make of those what it will, the storage, of the memories,
    in-memory, and that's great.


    Then, these accessors & mutators, or "scanners & printers", the
    conversion & formatting, variously are re-entrant or not, variously
    need buffers or not, variously are re-orderable by the compiler or
    not, and variously are thusly needing memory-management as
    buffer-management up-front, about the code & data segments, the
    stack-segment,
    and the heap.

    So, with many or deeply these conversion & formatting routines,
    there's that somewhere between the static (and extern), and
    the thread-local, and the code & data, and the stack, and the heap,
    how to have that so the stack doesn't overflow, the code & data isn't overlarge, and the heap isn't over-churned.

    Then, when it all comes crashing down, for whatever reason,
    it also has to result that everything will be OK.





    "Okay" is sometimes said to be the word in widest usage throughout
    the world, and of ancient origins, where "hurricane" is the oldest
    word in the world, since before the pre-historic Bronze Age,
    and on both sides of the Atlantic/Pacific.


    Here though it just means "about perfect".



    Thanks for writing, I don't keep grudges.



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kaz Kylheku@3:633/10 to All on Tuesday, November 03, 2026 22:59:50
    On 2026-11-02, Ross Finlayson <ross.a.finlayson@gmail.com> wrote:
    If not, are there common compiler extensions to so indicate
    when a variable goes out of scope and make effects on it?

    Yes, GCC has extensions for it. There was talk about a "defer"
    mechanism for inclusion into ISO C.

    https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2895.htm

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca

    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Tuesday, November 03, 2026 23:12:03
    On Tue, 3 Nov 2026 09:02:32 -0800, Ross Finlayson wrote:

    Then, if one of these records has some dozens, scores, or hundreds
    of fields, among textual, numeric, and calendric built-in and
    user-defined types, then each one of these might need a buffer or
    buffers the scratch-pad or working-memory, as the working-memory of
    the conversion & formatting routines, since for example strtok and
    strtok_r and other accounts of the conversion & formatting after the accessor/mutator routines of the records their fields in accounts of structured programming: are always using temporaries, here
    "automatic temporary arrays", their buffers.

    Basically, a complex, dynamically-allocated data structure with an
    intricate collection of components which themselves need dynamic
    allocation? Need to deal with errors that might occur during the setup
    and usage of such a structure, to ensure that all memory allocated is
    properly freed, without the chance of double-frees or memory leaks?

    Been there, done that. I use a technique called ?structured
    programming? to deal with the whole issue.

    Have a look at this project: <https://gitlab.com/ldo/a_structured_discipline_of_programming>. The
    README gives an introduction to the concept, and the sample code
    illustrates it in (I hope) exhaustive detail.

    --- 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 Tuesday, November 03, 2026 16:17:07
    On 11/03/2026 03:12 PM, Lawrence D?Oliveiro wrote:
    On Tue, 3 Nov 2026 09:02:32 -0800, Ross Finlayson wrote:

    Then, if one of these records has some dozens, scores, or hundreds
    of fields, among textual, numeric, and calendric built-in and
    user-defined types, then each one of these might need a buffer or
    buffers the scratch-pad or working-memory, as the working-memory of
    the conversion & formatting routines, since for example strtok and
    strtok_r and other accounts of the conversion & formatting after the
    accessor/mutator routines of the records their fields in accounts of
    structured programming: are always using temporaries, here
    "automatic temporary arrays", their buffers.

    Basically, a complex, dynamically-allocated data structure with an
    intricate collection of components which themselves need dynamic
    allocation? Need to deal with errors that might occur during the setup
    and usage of such a structure, to ensure that all memory allocated is properly freed, without the chance of double-frees or memory leaks?

    Been there, done that. I use a technique called ?structured
    programming? to deal with the whole issue.

    Have a look at this project: <https://gitlab.com/ldo/a_structured_discipline_of_programming>. The
    README gives an introduction to the concept, and the sample code
    illustrates it in (I hope) exhaustive detail.



    Well, thanks all, looking directly at variable-length-arrays,
    it seems that variable-length-arrays solve my riddle with
    making "automatic temporary arrays" as reside in the stack-segment
    and are block-scoped and while perhaps to be touched before access
    to avoid page-faults, are just the thing.


    So, elsewhere:

    __attribute__((noinline))
    size_t pg_sz() {
    return 2 * PAGE_SIZE - 1;
    }

    ptr_t pg_algn(ptr_t stack_offset) {
    return stack_offset + PAGE_SIZE - 1 - (stack_offset & (PAGE_SIZE - 1));
    }

    #define PG_BUF ({ size_t _pg_sz = pg_sz(); char
    _unaligned_stack[_pg_sz]; (char*) pg_algn((ptr_t) _unaligned_stack); })



    Then, chatting with the bot tells me that "variable-length-array
    declaration" has some specific syntax involved, as if array declarations
    the initialization weren't already quite various though nice once
    figured, and it tells me that the "macro" to result this
    PAGE_SIZE buffer resident in the stack-segment has that ANSI C
    would have to have passed the name and then string-token-concatenate
    it "##", that though "GCC/Clang" "statement expressions" make for this
    sort of macro.


    Then, somewhere:


    char* __restrict__ buf = PG_BUF;







    Why I'm looking for this "automatic temporary arrays", is that I've
    tapping away at some low-level code for text, i.e. Unicode text,
    called "Viswath & Charmaigne", as I tapped up over at comp.theory,
    then with that being a bunch of assembler macros, about an algorithm/procedure/routine/function setup, then I started looking
    at ye olde "string atomization" or as with regards to handles or
    internment of strings, "Atomenom", for this sort of "mechanical
    sympathy", about cache-line-size, which is sort of 64B everywhere
    and mostly in pairs of those, page-size, which is mostly 4KiB everywhere
    yet according to PAGE_SIZE, then as with regards to small/medium/large
    pages, and about general-purpose processor
    widths as 64-bit or "Gompath" I'm calling it, then about the
    vector-register widths as 128-bit then in tandem units for what can make
    shift & rotate, the "Viswath" bit, then as getting into what would
    be free-lists of PAGE_SIZE to be passed around, first wanted to get
    figured out "automatic temporaries" of PAGE_SIZE to not be passed around.




    Thanks, I think I solved my problem by "not re-inventing the wheel".




    --- 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 Tuesday, November 03, 2026 16:39:16
    On 11/03/2026 03:12 PM, Lawrence D?Oliveiro wrote:
    On Tue, 3 Nov 2026 09:02:32 -0800, Ross Finlayson wrote:

    Then, if one of these records has some dozens, scores, or hundreds
    of fields, among textual, numeric, and calendric built-in and
    user-defined types, then each one of these might need a buffer or
    buffers the scratch-pad or working-memory, as the working-memory of
    the conversion & formatting routines, since for example strtok and
    strtok_r and other accounts of the conversion & formatting after the
    accessor/mutator routines of the records their fields in accounts of
    structured programming: are always using temporaries, here
    "automatic temporary arrays", their buffers.

    Basically, a complex, dynamically-allocated data structure with an
    intricate collection of components which themselves need dynamic
    allocation? Need to deal with errors that might occur during the setup
    and usage of such a structure, to ensure that all memory allocated is properly freed, without the chance of double-frees or memory leaks?

    Been there, done that. I use a technique called ?structured
    programming? to deal with the whole issue.

    Have a look at this project: <https://gitlab.com/ldo/a_structured_discipline_of_programming>. The
    README gives an introduction to the concept, and the sample code
    illustrates it in (I hope) exhaustive detail.


    Thanks I read this briefly and it reminds of "defensive programming",
    that "structured programming" makes me think of struct basically,
    and user-defined types. The defensive programming is a lot of things,
    like library-design and zero-trust and sanitizing-inputs and Postel's
    law and Murphy's law and discipline-through-idiom and things like
    "no gotos" or usually "no early exits" and for some things like
    "error modeling & exception modeling", barriers, most usually though type-safety (after algorithm design modeling the happy, edge, and
    corner cases, and, the error & failure modes).



    About these ideas about string libraries, or Gompath & Viswath a
    "portable" model of general-purpose and vector registers and
    Charmaigne and "character machines", is that "string" the type
    is overloaded so much and opaque, then for accounts of noms & nyms
    for names about low-cardinality and high-cardinality languages,
    about Unicode and locale and regular expressions and parsers
    and deserializers and serializers and substring-matching and
    all these kinds of things, so usual.



    There's perceived a great requirement for "stability of interface",
    that re-write systems and term-graph-re-write and the like are so
    available yet opaque to the users, that since the explosion of
    "little languages" or "domain-specific languages", and those mostly
    or often not being very stable, vis-a-vis dotfiles everywhere and
    all these kinds of things, then for systems programming, it's figured
    that the modern commodity AMD & ARM (AMD/Intel & ARM) i-s-a's aren't
    going anywhere, and furthermore their accounts of the vector extensions
    have a common sub-set, compared to GPGPU's and the like which seem
    to change their interface every six months, then it's figured that
    things like text-processing and Unicode are ubiquitous and deserve
    a quite dedicated low-level "portable" systems-programming-compatible
    approach.



    Thanks again!



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wednesday, November 04, 2026 10:45:55
    Ross Finlayson <ross.a.finlayson@gmail.com> writes:
    [...]
    So, malloc and free are system-calls, in the implementation
    or the runtime or the O.S., and so when the structure is
    already in the code or data-segment, and needn't be
    re-entrant, then these system-calls can be reduced.

    The term "system call" (it's not hyphenated) has a specific meaning.
    On Linux-based systems, and many others, a system call is an entry
    point into the kernel. It's not a C concept.

    malloc and free are functions that are part of the C standard library.
    They are *not* typically implemented as system calls. Typically
    malloc() can operate in the context of the calling program, interacting
    with the kernel only when necessary. free() typically does the same,
    but doesn't return memory to the OS, so I wouldn't expect free() to
    result in any system calls.

    Some C library functions might be implemented as system calls (time(),
    for example) -- but that shouldn't matter most of the time.

    (There's also a library called named "system", which can cause some
    confusion; a call to system() is not a "system call".)

    [...]

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- 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 Wednesday, November 04, 2026 10:54:34


    Well, thanks all, looking directly at variable-length-arrays,
    it seems that variable-length-arrays solve my riddle with
    making "automatic temporary arrays" as reside in the stack-segment
    and are block-scoped and while perhaps to be touched before access
    to avoid page-faults, are just the thing.


    [ ... ]



    Thanks, I think I solved my problem by "not re-inventing the wheel".




    Then, it's figured there's a standard C way to make "automatic temporary arrays". Then there's alloca() when that's not available, else there isn't.

    So, then the next sort of perceived requirement here is about buffers
    and ownership of buffers and transfer, exchange, or passing of buffers
    in the ownership (and responsibility), when, for example, a buffer is
    partially filled in one thread-of-control, and passed to an I/O
    sub-system that correspondingly is under another thread-of-control,
    variously in user-space or kernel-space, which is undefined by C yet
    common in all commodity operating systems (with regards to executives
    and schedulers, those being simpler accounts of operating systems).


    Then, there's an idea, about how to handle thread-death, and basically
    about a two-state approach to free-lists, or freeable and freed,
    usually enough "acquire" and "release", when the relevant sub-system
    of I/O, might or might not have any way to indicate to free (or delete,
    to de-allocate, to release, to make discardable and discarded) the buffers.



    Then, there's considered a sort of belt-and-suspenders approach,
    to that a process allocates memory to build a free-list with a system
    call, about the various contexts of "heap memory" and also the section
    "direct memory" when that's separate about DMA and its usual role
    in I/O subsystems, then that only malloc (calloc, realloc) and free
    have semantics to the O.S. otherwise that the process must die for
    all what's malloc'ed to be free'd, when there are cases of thread-death
    or errors & exceptions, that a belt-and-suspenders approach involves interacting efforts to manage the resources, or redundancy.


    So, a usual allocation might figure to allocate a fixed amount of
    resources, then to use the sort of automatic throttling that in
    a web server or Internet server that it auto-throttles that when
    there are no available buffers that reads stop and the O.S. and NIC
    make TCP/IP advertise the window closing so TCP/IP makes back-pressure,
    that though the memory is all allocated up-front so that it's figured
    the run-time never grows in memory so that usual sorts of infrastructure deployments the nodes the runtimes the virtualized/chrooted account of multi-tenancy in server clusters and server processes and process-groups
    with cgroups after ulimit and the like and "Out-of-Memory Killer" and so
    on, make for usual expectations of long-lived processes and availability
    and uptime.

    Then, whether a linked-list or an array, of buffers, the free-list or free-array, makes for that I/O buffers come and go and not necessarily in-order, not necessarily that they're out-of-order, yet that they're
    formally un-ordered, as to why a free-list is usually the idea since
    that insertions and removals are O(1), yet that a free-array is usually
    the idea since that random-access is O(1), then about the constant fragmentation and de-fragmentation, usually that a list involves a lot
    of points, that for example when it's a fixed-size list, those can be an
    array the pointers, and they're followed by pointer increment and
    pointer addition, the pointers of the linked-list.

    So, besides the datum of the item in the list, then makes for probably
    a time-out or LRU eviction/reclamation policy, which though depends
    on the entire framework the longest-lived valid ownership, to be under
    that.



    So, since the usual consideration brings definition of POSIX after C
    brings definition, what that means is signals or out-of-band events that basically destroy the expectations of the behavior of the runtime, about
    that also the signal-handlers must be completely brief and non-blocking,
    else that the kernel may carp or choke, about "installing items from the free-list that were reserved yet not passed to another
    thread-of-control's responsibility to the signal-handler", that the signal-handler can release those, along with for example marking that it stomped or killed the thread that received it, as for the process as the process-of-control and the thread which is the thread-of-control.



    So, here then there's an idea about the thread-of-control, there's
    basically for that I'm not too familiar the semantics of basically
    "POSIX, or, Windows", of what signals make for semantics, or in the
    world of structured-exception-handling or SEH in Windows, say, of
    thread-death or thread-join or cascading signals, what would define then whether post-signal, the thread, could detect, courtesy a thread-local-variable, for example, whether, and how, it should cleanup
    itself, since it was interrupted by a signal. Then, whether that's
    recoverable or irrecoverable, fatal, after accounts of the PCB process-control-block and the TCB thread-control-block, those being
    common concepts among operating systems their schedulers, if not saying
    much about "fibers" or similar sorts accounts of "not-quite-threads, not-quite-processes", about how to make it so that usual server
    processes are long-lived and to handle both the burst-y and the idle,
    without tipping over.



    So, now my question is how to approach the usual sort of commodity
    operating system its runtime, for example POSIX and C, to be a good
    actor in the resource management, in a setting that's mostly organized
    about co-operative asynchrony for concurrency.








    --- 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 Wednesday, November 04, 2026 15:56:18
    On 11/04/2026 10:54 AM, Ross Finlayson wrote:


    Well, thanks all, looking directly at variable-length-arrays,
    it seems that variable-length-arrays solve my riddle with
    making "automatic temporary arrays" as reside in the stack-segment
    and are block-scoped and while perhaps to be touched before access
    to avoid page-faults, are just the thing.


    [ ... ]



    Thanks, I think I solved my problem by "not re-inventing the wheel".




    Then, it's figured there's a standard C way to make "automatic temporary arrays". Then there's alloca() when that's not available, else there isn't.

    So, then the next sort of perceived requirement here is about buffers
    and ownership of buffers and transfer, exchange, or passing of buffers
    in the ownership (and responsibility), when, for example, a buffer is partially filled in one thread-of-control, and passed to an I/O
    sub-system that correspondingly is under another thread-of-control,
    variously in user-space or kernel-space, which is undefined by C yet
    common in all commodity operating systems (with regards to executives
    and schedulers, those being simpler accounts of operating systems).


    Then, there's an idea, about how to handle thread-death, and basically
    about a two-state approach to free-lists, or freeable and freed,
    usually enough "acquire" and "release", when the relevant sub-system
    of I/O, might or might not have any way to indicate to free (or delete,
    to de-allocate, to release, to make discardable and discarded) the buffers.



    Then, there's considered a sort of belt-and-suspenders approach,
    to that a process allocates memory to build a free-list with a system
    call, about the various contexts of "heap memory" and also the section "direct memory" when that's separate about DMA and its usual role
    in I/O subsystems, then that only malloc (calloc, realloc) and free
    have semantics to the O.S. otherwise that the process must die for
    all what's malloc'ed to be free'd, when there are cases of thread-death
    or errors & exceptions, that a belt-and-suspenders approach involves interacting efforts to manage the resources, or redundancy.


    So, a usual allocation might figure to allocate a fixed amount of
    resources, then to use the sort of automatic throttling that in
    a web server or Internet server that it auto-throttles that when
    there are no available buffers that reads stop and the O.S. and NIC
    make TCP/IP advertise the window closing so TCP/IP makes back-pressure,
    that though the memory is all allocated up-front so that it's figured
    the run-time never grows in memory so that usual sorts of infrastructure deployments the nodes the runtimes the virtualized/chrooted account of multi-tenancy in server clusters and server processes and process-groups
    with cgroups after ulimit and the like and "Out-of-Memory Killer" and so
    on, make for usual expectations of long-lived processes and availability
    and uptime.

    Then, whether a linked-list or an array, of buffers, the free-list or free-array, makes for that I/O buffers come and go and not necessarily in-order, not necessarily that they're out-of-order, yet that they're formally un-ordered, as to why a free-list is usually the idea since
    that insertions and removals are O(1), yet that a free-array is usually
    the idea since that random-access is O(1), then about the constant fragmentation and de-fragmentation, usually that a list involves a lot
    of points, that for example when it's a fixed-size list, those can be an array the pointers, and they're followed by pointer increment and
    pointer addition, the pointers of the linked-list.

    So, besides the datum of the item in the list, then makes for probably
    a time-out or LRU eviction/reclamation policy, which though depends
    on the entire framework the longest-lived valid ownership, to be under
    that.



    So, since the usual consideration brings definition of POSIX after C
    brings definition, what that means is signals or out-of-band events that basically destroy the expectations of the behavior of the runtime, about
    that also the signal-handlers must be completely brief and non-blocking,
    else that the kernel may carp or choke, about "installing items from the free-list that were reserved yet not passed to another
    thread-of-control's responsibility to the signal-handler", that the signal-handler can release those, along with for example marking that it stomped or killed the thread that received it, as for the process as the process-of-control and the thread which is the thread-of-control.



    So, here then there's an idea about the thread-of-control, there's
    basically for that I'm not too familiar the semantics of basically
    "POSIX, or, Windows", of what signals make for semantics, or in the
    world of structured-exception-handling or SEH in Windows, say, of thread-death or thread-join or cascading signals, what would define then whether post-signal, the thread, could detect, courtesy a thread-local-variable, for example, whether, and how, it should cleanup itself, since it was interrupted by a signal. Then, whether that's recoverable or irrecoverable, fatal, after accounts of the PCB process-control-block and the TCB thread-control-block, those being
    common concepts among operating systems their schedulers, if not saying
    much about "fibers" or similar sorts accounts of "not-quite-threads, not-quite-processes", about how to make it so that usual server
    processes are long-lived and to handle both the burst-y and the idle,
    without tipping over.



    So, now my question is how to approach the usual sort of commodity
    operating system its runtime, for example POSIX and C, to be a good
    actor in the resource management, in a setting that's mostly organized
    about co-operative asynchrony for concurrency.









    (I copied a long bot-chat about it to comp.theory under "Portable, Safe Parallel-Semantic Protocol Servers". Long story short it's about compare-and-swap & LL/SC on AMD & ARM about execution & interruption
    in POSIX & Windows about processes & threads in C & assembly.)



    --- PyGate Linux v1.5.19
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)