Thanks a lot Sven. This is great to see all this positive energy to improve this part. >From a core library stand point, streams were the last pieces that needed to be revisited. This is great to see this happening.
Stef On Sun, Apr 22, 2018 at 11:04 AM, Sven Van Caekenberghe <[email protected]> wrote: > > >> On 22 Apr 2018, at 10:22, Tudor Girba <[email protected]> wrote: >> >> Hi, >> >> I am so looking forward to playing with this (as a user). >> >> For various reasons, we are still in Pharo 6.1, but encoding/decoding was >> always a troublesome issue in Pharo. > > Well it should not be, not even in older Pharo versions, as long as you use > everything correctly. > > But the latest changes are a bold step forward. > >> Thanks a lot! >> >> Cheers, >> Doru >> >> >>> On Apr 20, 2018, at 5:24 PM, Sven Van Caekenberghe <[email protected]> wrote: >>> >>> Hi, >>> >>> After the File and Stream changes in Pharo 7, a binary read, resp. write >>> stream from/to a file is actually a ZnBuffered(Read|Write)Stream on a >>> BinaryFileStream. You access these using #binary(Read|Write)Stream[Do:] >>> sent to a FileReference. >>> >>> As minimal streams the API of ZnBuffered(Read|Write)Stream was different >>> from what existed before. >>> >>> Specifically, a number of Integer decoding/encoding methods were missing. >>> It is probably best to add those (an alternative would be a subclass). >>> >>> When I looked at what was available, I thought I could improve upon the >>> current situation. In fact, I think all existing ones can be written in >>> terms of just one key method, one for reading and one for writing. The >>> existing methods than become simple aliases, all while offering more >>> functionality. >>> >>> (Incidentally this would be an ideal use of a Trait, can we use them >>> again/still ?) >>> >>> The key method is #nextIntegerOfSize: numberOfBytes signed: signed >>> bigEndian: bigEndian [put: value] and can be found in the latest version of >>> Zinc-CharacterEncoding-Core with a comprehensive set of unit tests. >>> >>> For example, >>> >>> int32 >>> ^ self nextIntegerOfSize: 4 signed: true bigEndian: true >>> >>> nextWord >>> ^ self nextIntegerOfSize: 2 signed: false bigEndian: true >>> >>> or non-aliases ones like >>> >>> binaryStream nextIntegerOfSize: 3 signed: true bigEndian: false >>> >>> I think I nailed it, but I would love a second pair of eyes to check what I >>> did. >>> >>> The same functionality could be added to ByteArray in a slight variation >>> (with offsets), where similar integer encoding/decoding methods exist. >>> >>> Sven >> >> -- >> www.tudorgirba.com >> www.feenk.com >> >> "From an abstract enough point of view, any two things are similar." >> >> >> >> >> > >
