help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: why are there [v e c t o r s] in Lisp?


From: Random832
Subject: Re: why are there [v e c t o r s] in Lisp?
Date: Thu, 15 Oct 2015 22:56:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:
> If a list just contains say a bunch of known integers
> that don't need to be computed, is there anything that
> stops this list from being stored in "contiguous
> memory" with the list functions as well as the
> constant access time "vector" functions available?

Well, what happens if you cdr that list? Does it make a
copy? Wasted memory, wasted time, won't track if you change
the original. Yeah, yeah, in platonic ideal lisp you *can't*
change lists, but this is the real world, where even scheme
lets you do it. Does it keep a reference to the original
list? Then what if you take the cd^{4000}r of a list of
5000, then throw away the original?  Wasted memory
again. Java used to have this issue with strings. I suppose
you could have the underlying array somehow know what the
earliest index that a reference actually exists for is, and
magically throw away everything before it during garbage
collection, if there's too much wasted space. But that seems
rather a lot of work.

> By the way: in my previous post strings were mentioned
> and it sounded like they were sugar for lists of chars
> - this isn't the case (you can't `car' a string) but
> it could have been and it isn't harmful (I think) to
> think of strings that way.

The thing is, if you can car a string people will wonder why
you can't cdr it. And with mutable objects it's hard to make
cdr work right. (fsvo "right")




reply via email to

[Prev in Thread] Current Thread [Next in Thread]