PositionableStream>>uint32 etc...??
Yoshiki.Ohshima at acm.org
Yoshiki.Ohshima at acm.org
Tue Jul 8 19:36:27 UTC 2003
Michael,
> Hi all, esp whoever uses the initials "yo" or "jm".
Oh, well, "yo" is me and "jm" is John Maloney. (He is also known as
'jhm'...) But, I think I'm not as guilty as he is for this matter^^;
> 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.
Yes, some of them are redundant.
> 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.
Probably. This is hard to explain, but if you've got the spec of a
message packet from someone that looks like:
| header <int8> | type <uint16> | nField <uint32> | ...
and want to fill the packet with some values, I would want to write a
method look like:
fillPacketWithHeader: header type: type nField: nField
aStream int8: header.
aStream uint16: type.
aStream uint32: nField.
because the method seems to concentrate aStream more on those values,
and it is easier to see the result conforms the format.
You can still say:
fillPacketWithHeader: header type: type nField: nField
header writeInt8On: aStream.
type writeUint16On: aStream.
nField writeUint32On: aStream.
But it at least looks longer^^;
I don't know about making them primitives... Why do you want them
be primitives?
> 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 :-) ).
Hmm. I am kind of ok with the current situation. DataStream
implements bunch of #writeBlah: so you can take a look at a single
method category and figure out what it does.
-- Yoshiki
More information about the Squeak-dev
mailing list
|