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

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

Re: LISP Questions - random, random elements and memory management


From: Jeff Clough
Subject: Re: LISP Questions - random, random elements and memory management
Date: Thu, 19 Nov 2009 06:56:56 -0500 (EST)

From: Kevin Rodgers <address@hidden>
Date: Wed, 18 Nov 2009 20:03:51 -0700

> The data *is* in memory.  The function is zippy because nth is fast,
> in
> turn because cdr is fast (and implemented in C).  And perhaps the cons
> cells for the list are allocated in adjacent memory, if it is
> constructed all at once.
> 
> Of course you can put the data (defconst forms) and function (defun)
> in
> the same .el file!

Um, actually I was looking for a way that would allow me to keep the
data *out* of memory until it was needed, then toss it on the floor
when I was done, that way I'm only eating the RAM *some* of the time
instead of all the time.  With my existing scheme, the data is in
memory as soon as the .el file is loaded.

And yes, as your earlier message indicates, the relevant line would
be:

(nth (random (length list)) list)

Overall update:

In absence of reaching enlightenment with the other points, I think
I'm just going to use the above line in my name generator instead of
worrying about defining a new function, put a note in the source about
calling (random t) and not worry about the memory issue for now.

Jeff





reply via email to

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