vega,

Could you show a safe non-GC version of readInt proc (btw, it shouldn't exist 
in a networking lib because of undefined size and endianness of int)? As I see 
it, by introducing raw pointer **async** send/recv procs, stdlib would just 
move burden to the user. To safely implement readInt you would have to alloc 
memory on heap (because stack will be destroyed in a moment - it is async), 
then, when recv is finished, copyMem from there into result, then dealloc. It 
feels that the amount of overhead would be somewhat similar to seq[byte]/string 
version.

Serialization procedures normally work with strings. Beyond sending/receiving 
strings one usually needs sending/receiving basic types in binary form 
(integers, floats, bools, etc.). So I think it makes more sense to implement 
the latter in stdlib and either hide unsafe procs from the user or rename them 
to unsafeSend, unsafeRecv so that it is crystal clear you shouldn't use them 
unless you understand what you are doing.

Reply via email to