Re: I wonder if I'm missing something...
"David McClain (as dbm at refined-audiometrics dot com)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
I just downloaded the source code for SBCL to see one example of how things are implemented in Lisp. And I just discovered that READ-SEQUENCE is a Generic Function that can be applied to many different kinds of streams, including ones we make up for ourselves. But then I also just realized that READ-SEQUENCE is really trying to join two different worlds together - a stream world, and a sequence world. And what I’m asking for is really more of a sequence world thing - being able to view the contents of a sequence in more than one way. We already have that with SYS:TYPED-AREF, but we don’t have Streams operating on them directly. Alternatively, since, in my case, I know that I’m expecting a bunch of raw single-precision floats coming at me over the socket connection, I could try to fancy up a new Stream Class to incorporate the Socket Stream, and have that new stream chunk up the data into 4 bytes at a time, and then just deposit into a float array directly. Have that new stream class perform READ-SEQUENCE in the domain of the target types. Or have the new stream class operate against a SYS:TYPED-AREF vector. > On Nov 8, 2025, at 06:41, David McClain (as dbm at refined-audiometrics dot com) <[email protected]> wrote: > > It looks like Bindat also makes copies of data. > > The ideal solution would allow data to remain in place. It does not have to allow mutable access to the data. Most often the data are read-only. We just need to examine the data and make decisions based on values, or display them in graphs. > > And since we are talking about read-only access, I really don’t understand the aversion to multi-type overloading access. > > > >> On Nov 8, 2025, at 03:25, Marco Antoniotti <[email protected]> wrote: >> >> Hi everybody... >> >> interesting (and still unresolved after decades: we are getting old) issue. >> >> I have recently wor... ahem, wasted an inordinate amount of time on Emacs Lisp. >> >> I had to deal with similar issues and eventually used the bindat library, which I found interesting w.r.t. its interface. >> >> Any thoughts about it? >> >> All the best >> >> Marco >> >> >> On Sat, Nov 8, 2025 at 10:19 AM Tim Bradshaw (as tfb at tfeb dot org) <[email protected] <mailto:[email protected]>> wrote: >>> I think your approach is equivalent to mine except: >>> >>> - the transducers are explicitly symbols rather than opaque objects which the implementation gets to define (and there are potentially hundreds of distinct ones) >>> >>> - 'it should also support custom data types' turns it from a small soluble problem to a huge one with no general solution at all. >>> >>> On and the displaced array thing: (a) ick, just no, (b) this already solves David's problem (just make the displaced array be an array of (unsigned-byte 8)s and write-sequence does what you want. >>> >>> If you want C I hear that C compilers are quite commonly available now. >>> >>> --tim >>> >>> > On 7 Nov 2025, at 20:01, Yuri Davidovsky <[email protected] <mailto:[email protected]>> wrote: >>> > >>> > >>> > >>> >> On 7 Nov 2025, at 20:21, Tim Bradshaw <[email protected] <mailto:[email protected]>> wrote: >>> >> >>> >> Here is a sketch (which I may have mentioned here previously) of how functionality could be added to CL which would enable fast I/O of, for instance, vectors of floats without destroying the language by allowing arbitrary type punning, and also dealing with things like ensuring things are written in defined byte orders. >>> > >>> > Interesting. I was thinking of something different. Essentially any byte stream could be read (and written to) arbitrary data types using primitives like: >>> > >>> > (read-byte stream) — as is now. >>> > (read-byte stream :uint32) — will read an unsigned 32 bit int. >>> > (read-byte stream :float) — you start to get the idea. >>> > >>> > You could do the same with read-sequence by supplying the type of data to read and an array of appropriate type. It should also support custom data types. >>> > >>> > Also when creating a displaced array it should allow casting to a different type. >>> >>> >>> _______________________________________________ >>> Lisp Hug - the mailing list for LispWorks users >>> [email protected] <mailto:[email protected]> >>> http://www.lispworks.com/support/lisp-hug.html >> >> >> >> -- >> Marco Antoniotti, Professor, Director tel. +39 - 02 64 48 79 01 >> DISCo, University of Milan-Bicocca U14 2043 http://dcb.disco.unimib.it <http://dcb.disco.unimib.it/> >> Viale Sarca 336 >> I-20126 Milan (MI) ITALY >> >> REGAINS: https://regains.disco.unimib.it/ >