I
ImpalerCore
On 9/01/2011 23:31, jacob navia wrote:
Secondly, is there any method for serialisation in your library? I
certainly could have used one in the past
The documentation mentions Save and Load operations can be performed on
containers, but these take a FILE* as argument and so are useless if you
want to send data over the network[1], for instance, unless your OS
happens to have methods to address a block of memory through a FILE*.
It would be nice if serialisation just wrote to memory, and you
implemented Save/Load based on those serialisation/de-serialisation methods.
I imagine that one could implement a scenario like that using a
container 'foreach' function (I think Jacob's version is 'Apply').
Consider the following 'foreach' function type and an example
container that calls it.
typedef void (*foreach_function)( void* p, void* u );
void array_foreach( struct array* ar, foreach_function fn, void*
user_data );
Consider that 'array_foreach' visits each element (iter = 0->N-1) in
the array calling (*fn)( ar[iter], user_data ). One can pass a
container as 'user_data', and 'fn' would be responsible for both
converting the array element 'ar[iter]' into a string and then
inserting it into the container masquerading under 'user_data'. That
would convert an array of elements into their serialized versions
(let's just say that they're strings). Then one could have another
'foreach' function that visits a container of serialized strings
sending each string over the network to some destination ('user_data'
in that case could contain network destination information like ip
address/port). I think it's feasible, but one example would go a long
way. I think the tricky part is how do you communicate and handle
errors using a 'foreach' mechanism if you need to be concerned about
them (my answer is not to use 'foreach' in those scenarios). And it's
kind of fragile to programmer errors with all the 'void*' pointers
floating around.
Thirdly, what advantage does this project have to just using C++? Do you
really think eventually systems will exist where your library is
present, but a C++ compiler isn't? Yes, I don't like the STL either, but
it does the job and, anyway, there are alternatives[2].
Absent of language restrictions, you'd definitely get better bang for
your buck in the short term investing in learning the STL. However,
some projects do have arbitrarily defined language restrictions; and
other times programmers choose to invest in their own language related
preferences.
Best regards,
John D.