PositionableStream>>uint32 etc...??
Michael van der Gulik
mikevdg at hetnet.nl
Mon Jul 7 18:42:42 UTC 2003
Hi all, esp whoever uses the initials "yo" or "jm".
There's a bit of (what I consider, as an unqualified newbie) untidyness
in PositionableStream. Under the method categories "nonhomogenous
access" and "data get/put", there are a whole bunch of rather useful
methods. Some of these are duplicated, further proving that they are
needed and useful. These are namely things like "uint32" and "uint32:"
which retrieve and put unsigned 32-bit integers on a stream.
However - wouldn't these be better as methods of those respective data
types? I.e.
SmallInteger>>putAsUInt32On: aStream
or better:
SmallInteger>>writeOn: aStream
etc.. ?? Furthermore, shouldn't these be primitives? Things like Magma
reimplement these as primitives.
My argument for these being in the class of the respective data types
(SmallInteger etc) is that it is the class that should know about the
format of that data structure in bytes, and not a stream.
Furthermore, if all objects supported something like a writeOn: method,
serialization would be easy. References are tricky though - they would
probably call "aStream writeReferenceOf: self" so that the Stream can do
fancy things with references (like ImageSegments :-) ).
Michael.
More information about the Squeak-dev
mailing list
|