From: Taylan Kammer <taylan.kammer@gmail.com>
To: Vijay Marupudi <vijaymarupudi@gatech.edu>, guile-devel@gnu.org
Subject: Re: Request to add *-resize! functions for contiguous mutable data structures.
Date: Sat, 7 Aug 2021 12:31:09 +0200 [thread overview]
Message-ID: <5de0d09e-263a-20e3-a0d0-7868593db585@gmail.com> (raw)
In-Reply-To: <97e4262b-3ff9-1b21-35d8-45ad9d45ca99@gatech.edu>
On 06.08.2021 16:33, Vijay Marupudi wrote:
> Hello!
>
> I was curious if Guile would be willing to provide a series of
> new procedures for resizing contiguous memory regions.
>
> (bytevector-resize! <bytevector> new-size [fill])
> (vector-resize! <vector> new-size [fill])
>
> The [fill] parameter could be used if the new-size is bigger than
> the current size.
>
> This would make writing imperative code easier and more
> performant. I acknowledge that it is not idiomatic Scheme to use
> mutable data structures, however this is useful to me for
> dealing with large amounts of text data, in which I need random
> access and flexible data storage. It would allow me to move off
> my custom C extension vector and allow me to use other
> vector-* functions.
>
> Ideally, this would use libc's `realloc` to make the resize
> quick, so that it can avoid data copying whenever possible.
>
> Regards
>
> Vijay Marupudi
> PhD Student in Human Centered-Computing
> Georgia Tech
>
Sounds like a good idea to me. I didn't know realloc() was a
thing in C (I don't write much C) and I suppose it's not possible
to implement equivalent functionality with equivalent performance
purely in Scheme.
I'm on vacation for the next three weeks and will try to write a
patch to implement this if no one beats me to it. :-)
One consideration is how this should behave in the case of
bytevectors that were created from an FFI pointer. In the FFI,
you provide a pointer and specify how long the bytevector should
be, which means it's a memory-unsafe operation. I think it would
be ideal to offer a way of forcing an in-place resize, basically
overriding the formerly provided size value. That means it's
also memory-unsafe, but in some cases that's what you want.
--
Taylan
next prev parent reply other threads:[~2021-08-07 10:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-06 14:33 Request to add *-resize! functions for contiguous mutable data structures Vijay Marupudi
2021-08-07 10:31 ` Taylan Kammer [this message]
2021-08-07 21:19 ` tomas
2021-08-08 12:17 ` Taylan Kammer
2021-08-07 11:09 ` Maxime Devos
2021-08-07 17:46 ` Taylan Kammer
2021-08-09 4:02 ` Vijay Marupudi
2021-08-09 18:24 ` Maxime Devos
2021-08-09 18:35 ` Vijay Marupudi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5de0d09e-263a-20e3-a0d0-7868593db585@gmail.com \
--to=taylan.kammer@gmail.com \
--cc=guile-devel@gnu.org \
--cc=vijaymarupudi@gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).