S
spinoza1111
FIT THE FIRST: WE DEVELOP STRINGS AS A STRUCT
OK, this is spinoza1111. In this thread I shall re-learn C, being
still crazy after all these years.
To do ANYTHING with C, I need a string handler. No, I don't want
yours, Richard Heathfield. The point is this is a good way of (1)
relearning C and (2) demonstrating that C sucks.
I will take this step by step in order to give everyone a chance to
comment. Comments are welcome from all especially Navia, Heathfield,
Bacarisse and Malcolm M.
For now, I will use the Navia compiler, but shall restrict myself to
as vanilla a subset of C as is possible. I shall only use #includes I
absolutely need. I shall incorporate changes suggested by others, of
course!
OK, so here's how I represent strings:
struct TYPstring
{
long intSegmentLength;
char * strSegment;
void * usrLeftSegment;
void * usrRightSegment;
};
That is (das ist) a string is a binary tree of segments, giving it
unlimited length and avoiding Stupid Sentinels. Each segment is at
most 2^31 - 1 wide characters long, but there is no apriori bound to
the tree: therefore the above structure represents strings.
Two problems:
1. It seems I cannot include what I want to be a self-referential
struct inside a struct either as the thing itself or as a pointer
because either C or the Navia compiler is basically one-pass. I can't
do this in C Sharp either but can if I change the struct to a class.
So, void pointers raise their pretty little heads.
But: note that there's no point in a"void"ing void pointers in C
because C makes it easy to change pointer type. If there is no modern
try..catch in C then the only way of detecting whether you have a
pointer to a valid data type is to examine memory at the place where
the pointer points.
2. With minimal assumptions (that is, minimal #includes) I default to
char and not wchar.
Of course, I might be "erring" in using the Navia compiler. But my
actual situation reflects that of the real C programmer who is
confronted with mutually incompatible compilers. This is because C was
misdesigned, misbegotten, dead on arrival,
"...curtail'd of this fair proportion,
Cheated of feature by dissembling nature,
Deformed, unfinish'd, sent before my time
Into this breathing world, scarce half made up," (Shakespeare, Richard
III)
and never standardized until way too late.
Let the fun begin...
OK, this is spinoza1111. In this thread I shall re-learn C, being
still crazy after all these years.
To do ANYTHING with C, I need a string handler. No, I don't want
yours, Richard Heathfield. The point is this is a good way of (1)
relearning C and (2) demonstrating that C sucks.
I will take this step by step in order to give everyone a chance to
comment. Comments are welcome from all especially Navia, Heathfield,
Bacarisse and Malcolm M.
For now, I will use the Navia compiler, but shall restrict myself to
as vanilla a subset of C as is possible. I shall only use #includes I
absolutely need. I shall incorporate changes suggested by others, of
course!
OK, so here's how I represent strings:
struct TYPstring
{
long intSegmentLength;
char * strSegment;
void * usrLeftSegment;
void * usrRightSegment;
};
That is (das ist) a string is a binary tree of segments, giving it
unlimited length and avoiding Stupid Sentinels. Each segment is at
most 2^31 - 1 wide characters long, but there is no apriori bound to
the tree: therefore the above structure represents strings.
Two problems:
1. It seems I cannot include what I want to be a self-referential
struct inside a struct either as the thing itself or as a pointer
because either C or the Navia compiler is basically one-pass. I can't
do this in C Sharp either but can if I change the struct to a class.
So, void pointers raise their pretty little heads.
But: note that there's no point in a"void"ing void pointers in C
because C makes it easy to change pointer type. If there is no modern
try..catch in C then the only way of detecting whether you have a
pointer to a valid data type is to examine memory at the place where
the pointer points.
2. With minimal assumptions (that is, minimal #includes) I default to
char and not wchar.
Of course, I might be "erring" in using the Navia compiler. But my
actual situation reflects that of the real C programmer who is
confronted with mutually incompatible compilers. This is because C was
misdesigned, misbegotten, dead on arrival,
"...curtail'd of this fair proportion,
Cheated of feature by dissembling nature,
Deformed, unfinish'd, sent before my time
Into this breathing world, scarce half made up," (Shakespeare, Richard
III)
and never standardized until way too late.
Let the fun begin...