E
Eric Sosman
Chris Thomasson wrote On 10/05/07 06:14,:
Perhaps it might be too ambitious to begin with
something as advanced as a stack. How about starting
with a lower-level data structure, just to get the
hang of designing API's that the C community at large
will find useful? How about a suite of functions to
manage an array of elements, for example?
struct ArrayHandle *
ArrayCreate(size_t count, size_t esize);
void
ArrayStore(struct ArrayHandle *handle,
size_t index, const void *pdata);
void
ArrayFetch(struct ArrayHandle *handle,
size_t index, void *pdata);
void
ArrayDestroy(struct ArrayHandle *handle);
Hmmm... Given the somewhat contentious tone of
the C discussion groups, even that might be too
controversial. It might be more prudent to begin
with an API for manipulating int values, like
int IntAdd(int x, int y);
int IntSubtract(int x, int y);
int IntMultiply(int x, int y);
int IntDivide(int x, int y);
int IntModulus(int x, int y);
_Bool IntLessThan(int x, int y);
_Bool IntLessThanOrEqual(int x, int y);
_Bool IntEqual(int x, int y);
_Bool IntGreaterThanOrEqual(int x, int y);
_Bool IntGreaterThan(int x, int y);
_Bool IntNotEqual(int x, int y);
int IntShiftLeft(int x, int bits);
int IntShiftRight(int x, int bits);
int IntAnd(int x, int y);
int IntInclusiveOr(int x, int y);
int IntExclusiveOr(int x, int y);
int IntUnaryMinus(int x);
int IntUnaryPlus(int x);
int IntComplement(int x);
long IntPromoteToLong(int x);
int LongDemoteToInt(long x);
int ShortPromoteToInt(short x);
short IntDemoteToShort(int x);
...
(For efficiency's sake, some of these functions might
also be implemented with masking macros.)
Comments?
Humm... I will post an example LIFO linked collection API (e.g. stack) in a
day or two. We should be able to tear it apart into something usable... A
simple standardized API wrt this newsgroup could be beneficial. Well, any
question that deals with common/trivial collection abstractions can be
directed at the various implementations of this newsgroups standardized API.
There is only one requirement I would personally leverage against any
submission: The KISS principal should be the main goal... C is low-level,
therefore we should keep anything we create for this group bound to the land
of minimalism...
Any thoughts?
Perhaps it might be too ambitious to begin with
something as advanced as a stack. How about starting
with a lower-level data structure, just to get the
hang of designing API's that the C community at large
will find useful? How about a suite of functions to
manage an array of elements, for example?
struct ArrayHandle *
ArrayCreate(size_t count, size_t esize);
void
ArrayStore(struct ArrayHandle *handle,
size_t index, const void *pdata);
void
ArrayFetch(struct ArrayHandle *handle,
size_t index, void *pdata);
void
ArrayDestroy(struct ArrayHandle *handle);
Hmmm... Given the somewhat contentious tone of
the C discussion groups, even that might be too
controversial. It might be more prudent to begin
with an API for manipulating int values, like
int IntAdd(int x, int y);
int IntSubtract(int x, int y);
int IntMultiply(int x, int y);
int IntDivide(int x, int y);
int IntModulus(int x, int y);
_Bool IntLessThan(int x, int y);
_Bool IntLessThanOrEqual(int x, int y);
_Bool IntEqual(int x, int y);
_Bool IntGreaterThanOrEqual(int x, int y);
_Bool IntGreaterThan(int x, int y);
_Bool IntNotEqual(int x, int y);
int IntShiftLeft(int x, int bits);
int IntShiftRight(int x, int bits);
int IntAnd(int x, int y);
int IntInclusiveOr(int x, int y);
int IntExclusiveOr(int x, int y);
int IntUnaryMinus(int x);
int IntUnaryPlus(int x);
int IntComplement(int x);
long IntPromoteToLong(int x);
int LongDemoteToInt(long x);
int ShortPromoteToInt(short x);
short IntDemoteToShort(int x);
...
(For efficiency's sake, some of these functions might
also be implemented with masking macros.)
Comments?