[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vectors of numbers

This page is part of the web mail archives of SRFI 56 from before July 7th, 2015. The new archives for SRFI 56 contain all messages, not just those from before July 7th, 2015.



At Tue, 28 Sep 2004 13:54:43 +0200, sebastian.egner@xxxxxxxxxxx wrote:
> 
> Did you consider the idea of extending the interface to vectors
> of numbers? In other words, in each place where a write procedure
> accepts an /int/ it would also accept a vector of /int/ and write the
> components of the vector one by one.

Something simlar was suggested in pre-list discussion, though the idea
was that the elements would always be single bytes, allowing you to
simulate larger integer types when the Scheme implementation doesn't
support bignums.  For easier portability with such Schemes I may
include this, something like

  (read-byte-vector! vec [port])
  (write-byte-vector vec [port])

but these would be normal vectors.

> This is a conceptually simple way to improve performance without
> much impact or special constructs in Scheme-land. Lazy implementors
> can simply catch the vector case and pass it to a loop.

This is a fairly minimal improvement at the expense of extra type
checking and complexity on every read/write int procedure.  It would
be much more worthwhile if you allowed uniform vectors, since then you
can work with whole blocks of memory without [un]boxing, but this
falls back to the other thread.

-- 
Alex