This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: Something like vector-grow available?
> is there an easy way to grow a vector dynamically? At the moment I
> allocate a new one and copy all elements to this new vector.
>
> Is there a more elegant solution?
Just use:
(set! (vector-length v) 50)
Oh, hang on, I keep thinking that we have already caught up with perl.
AFAIK, no there is not. The implementation of a vector is a simple malloc()
and the chances for a realloc() on that working without doing a copy are
pretty small. The copy inside realloc() is faster than anything you write
in scheme though. Adding a vector-grow function to guile might be nice for
just that reason and possibly for the reason that some future implementation
might be smarter.
- Tel