B
Brian
Nick said:Nick said:On 16 Sep, 09:16, "Brian" <BWeird!@internet.> wrote:[...] I don't usually post code because it's all really "top
secret"you program missiles?!but I think it [bit manipulation] should be
fixed once and then used "forever" rather than dealt with at every
line of code for that is a waste of human effort and money.yes, this is correct. A set of bit handling abstractions *is* a good
idea if your code is doing a lot of bit manipulation. Where did you
get the idea that anyone was disagreeing. Where we part company is
if your macros are powerful (they aren't, they are trivial),
It's just bit twiddling. How "powerful" can they be?!
well I guess you posted em for a reason. I assummed there was some
implied significance. I was thinking of "bit streams" where you can
write multiple bits.
I thought it was obvious where they are useful and even gave an example
in the original post. Some may call that premature optimization maybe but
it is done for more reason than just the space efficiency.
fair enough
ah, the missiles. These are not the missiles I am looking for...
you build on the standard stuff when you can.
Wrong, I do not. I used to, but that was many years ago. It's a common
failing, IMO, to buy into things without thinking about them enough. It
takes years to "get it" and most probably never will or become
evangelical about it along with "the group". The best way to learn how to
write software for the long term is to replace as much of the canned
stuff as possible. Even if done just from a learning perspective.
Then your extension/
abstraction is portable.
No, it's just standard. There are many ways to improve on standard APIs.
The standard is just the starting point, a means, not an end, and it's
not "all or nothing" either: use as much or as little as you feel is
appropriate.
In what sense is either standard "sub-
optimal"?
I admit C looked pretty strange when I started to use it.
Back when I first started using it (1989), I thought it was the best
thing since sliced bread, for all of my contemporaries were using
FORTRAN, and the IT guys were doing BASIC (a few years later?), and the
noobs from college were doing Pascal (I learned Pascal in college too,
along with FORTRAN, but never used them much even though FORTRAN was the
major codebase where I worked). The data acq guys were doing C though in
a big way and I had some ambition to get involved with that at the time
and I did write some data reduction programs that ran on their platforms.
I actually was glad that MS embraced standard C in addition to their APIs
and thought that was the way to go at the time, but I have long since
reconsidered and now build on top of the platform APIs rather than
standard C/C++ whenever possible. That said, I have been building my own
abstractions and constructs for years and am now taking it to the moon
(knock on wood).
You get used
to it. You'd be much better off persisting with the standard syntax
rather than hiding it. You'll be able to read other peoples' code and
they'll be able to read yours.
Reading anyone's C code is an excruciating experience. Ever heard the
phrase "C is a write-only language"? Just try to understand, use or reuse
any open source project code that isn't a libary.
so why post it? Were you expecting a gasp of universal astonishment at
your amazing code?
Of course! How about those names! They should be in the standard!
my rule is if there is a standard way of doing something and a non-
standard way of doing it then choose the standard way.
That's fine. That's a popular approach. "No one ever got fired for doing
it like everyone else".
Note this
doesn't exclude the use of libraries and other abstractions built on
top of the standard language and library.
That's another can of worms. It's one thing to actually use the standard
library, and quite another to build on it. I put the standard libs in 3rd
or 4th place after (in no particular order): the platform APIs, my own
APIs, someone else's APIs.
That's probably what these were based on. Or maybe FreeBSD? They are very
old but I redid them last week and I think I like the result. I posted
them up untested, but the gist of it is what I was trying to convey. I
have nice arbitrary-length bitset macros too.