I
Ike Naar
It's relevant to C because C makes it very obvious that you're bit-shuffling.
You seem to use word "shuffling" in an unconventional way. Usually,
"shuffling" is used to mean "changing the order of objects", without
changing the objects themselves. Like, when one shuffles a deck of
cards, the order of the cards changes, but the cards themselves
don't. When you shuffle, the cards change.
Because C makes it easy to access the actual binary bits,
Binary bits, for sure
it's clear how a C function can be rewritten in terms of shuffling
rather than higher-level concepts.
Not sure what you're saying here.
Can you give a simple example of a C function that can be rewritten in
terms of shuffling rather than higher-level concepts, and what such a
rewrite would look like?
Also because C makes asking for memory explicit. It's obvious that a
correctly-specified and written and called bit shuffling function can only
fail if it runs out of memory. If it's passed an arrangement of bits it can't
deal with (e.g. wild pointers), it's a programming error by caller, if it
executes an illegal operation on a valid input bitset, it's an internal
programming error. But it can always run out of memory, that's a sort of
inherent problem in specifying a function in terms of expected output state
given an input state.
If a program does not allocate dynamic memory and does not call
recursive functions, an upper limit for the required amount of
memory can be determined, with some effort, at compile time. If
such a program is started with a sufficient amount of memory it
can be guaranteed not to run out of memory during its lifetime.
In parts of the embedded world it is common practice to design
programs this way. It would't even matter if such a program performs
I/O, or if such a program is bit-shuffling (for whatever that
means).
In C, it's obvious what's happened, because malloc()
returns null. In other languages, the same underlying problem will happen,
but it's harder for the programmer to see.
Then the whole idea is ago separate out the bit-shuffling functions for the
IO procedures.
Sorry, can't parse that. Can you explain?
C makes that easy. If you don't include stdio.h or any third party
IO-headers, you're bit shuffling.
Elsethread you've said that functions that perform I/O also shuffle
bits. Can we conclude that *all* functions (that is, functions that
perform I/O *and* functions that don't perform I/O) shuffle bits?
If so, "bit shuffling" is a meaningless phrase.
Or is there a subtle distinction between a function that shuffles
bits and a bit shuffling function?
And since bit-shufling functions can be
idempotent, normally you won't need any third party headers anyway, So
you can see at a glance that the method has been applied.
A function f is said to be idempotent if, for all input x, f(f(x)) = f(x).
For instance, trunc() from <math.h> is such a function.
Apparently you have a different definition of idempotence in mind.
Can you clarify?