[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: One trivial querstion about datatype
From: |
Alex Shinn |
Subject: |
Re: One trivial querstion about datatype |
Date: |
23 Dec 2001 22:48:47 +0900 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1 |
>>>>> "Dmitry" == Dmitry Morozhnikov <address@hidden> writes:
Dmitry> Yes, thanks for detailed explanation! I adopt this (just
Dmitry> make allocation chunk of elements instread of one) and see
Dmitry> this have acceptable speed on adding elements.
Oh, if you're using that code, make sure you replace the < checks with
<= (obi-wan error, sorry).
AS> If you want something more like the list/array data types in
AS> scripting languages such as Python/Perl, where you want to
AS> quickly push elements onto either end of the data structure (
AS> treating them both as vectors and lists) then you might try a
AS> list of vectors rather than the single vector above. Appending
AS> ( pushing, etc.) applies the above approach to the last element
AS> of the list, and cons (unshift in Perl speak) then means
AS> cons'ing a new single element vector onto the front of the list
AS> (probably with consolidation routines).
Dmitry> It`s intresting.. Go look how it implemented in perl.. How
Dmitry> determine time when list of many vectors must be rebuilded
Dmitry> in one vector for fast referencing?
[warning: for any of you who got the urge *don't* look at the Perl
source... it's not pretty]
I wasn't suggesting implementing it the same as Perl, because Perl
arrays are fundamentally different animals from Scheme vectors. They're
much heavier, and meant to be all-purpose lists/vectors in one.
The Scheme approach is to give you the most "axiomatic" data types from
which you can build all other data types. To make this work well the
data types are very light-weight without a lot of the fluff from common
scripting languages. So vector-set-length! isn't so important because
you can accomplish the same thing in Scheme. Likewise I threw out an
idea (thinking while I typed) of how you might get the same sort of lazy
list/vector style data type in basic Scheme data-types. It may or may
not be any good :)
--
Alex