Re: bytevector-string-ref

2022-12-22 Thread lloda
> On 22 Dec 2022, at 09:58, Sascha Ziemann wrote: > >>> (define str "Hello, World!") >>> (define bv (string->utf8 str)) >>> (define sa (make-shared-array bv (lambda (i) (list (+ i 7))) '(0 4))) >> >> I think this should be >> >> (define sa (make-shared-array bv (lambda (i) (list (+ i 7))) 4

Re: bytevector-string-ref

2022-12-22 Thread Sascha Ziemann
> > (define str "Hello, World!") > > (define bv (string->utf8 str)) > > (define sa (make-shared-array bv (lambda (i) (list (+ i 7))) '(0 4))) > > I think this should be > > (define sa (make-shared-array bv (lambda (i) (list (+ i 7))) 4)) This seems to be the same (equal?): (make-shared-array bv

Re: bytevector-string-ref

2022-12-21 Thread tomas
On Wed, Dec 21, 2022 at 04:49:09PM +0100, Sascha Ziemann wrote: > > Is that related to "shared arrays"? This seems to be even more general (the > > affine part being the offset of the slice). > > Thanks for the hint. I was not aware of them. > > But I am struggling to use them. This does not work

Re: bytevector-string-ref

2022-12-21 Thread Sascha Ziemann
> Is that related to "shared arrays"? This seems to be even more general (the > affine part being the offset of the slice). Thanks for the hint. I was not aware of them. But I am struggling to use them. This does not work: (define str "Hello, World!") (define bv (string->utf8 str)) (define sa (m

Re: bytevector-string-ref

2022-12-18 Thread tomas
On Sun, Dec 18, 2022 at 11:45:49PM +0100, Sascha Ziemann wrote: > Maybe having a bytevector-slice-ref with shared memory would be more flexible. > The partial usage of a bytevector as a string is just one use case. > There may be others. Is that related to "shared arrays"? This seems to be even mo

Re: bytevector-string-ref

2022-12-18 Thread Sascha Ziemann
Maybe having a bytevector-slice-ref with shared memory would be more flexible. The partial usage of a bytevector as a string is just one use case. There may be others.

Re: bytevector-string-ref

2022-12-18 Thread Matt Wette
On 12/18/22 4:12 AM, Sascha Ziemann wrote: I am wondering if something like bytevector-string-ref is missing in the API. Or is there any other way to extract a string from a byte vector, without copying the data twice? I sympathize with the struggle here.   I wonder if rlb is aware. I believe

Re: bytevector-string-ref

2022-12-18 Thread Vijay Marupudi
The 2 copies occur if you want a portion of the bytevector to be converted to a string. The current API requires you to copy to a bytevector that's the length of the slice, and then convert that copy to a string. I've sent patches to guile-devel to address this issue (by extending utf{8,16,32}->st

Re: bytevector-string-ref

2022-12-18 Thread tomas
On Sun, Dec 18, 2022 at 05:25:16PM +0100, Taylan Kammer wrote: > On 18.12.2022 13:12, Sascha Ziemann wrote: > > I am wondering if something like bytevector-string-ref is missing in the > > API. > > Or is there any other way to extract a string from a byte vector, without

Re: bytevector-string-ref

2022-12-18 Thread Taylan Kammer
On 18.12.2022 13:12, Sascha Ziemann wrote: > I am wondering if something like bytevector-string-ref is missing in the API. > Or is there any other way to extract a string from a byte vector, without > copying the data twice? > I don't think Guile currently has any way of gi

Re: bytevector-string-ref

2022-12-18 Thread tomas
On Sun, Dec 18, 2022 at 01:12:57PM +0100, Sascha Ziemann wrote: > I am wondering if something like bytevector-string-ref is missing in the API. > Or is there any other way to extract a string from a byte vector, without > copying the data twice? Alas, it's more complicated than t

bytevector-string-ref

2022-12-18 Thread Sascha Ziemann
I am wondering if something like bytevector-string-ref is missing in the API. Or is there any other way to extract a string from a byte vector, without copying the data twice?