From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jeff Clough Newsgroups: gmane.emacs.help Subject: Re: LISP Questions - random, random elements and memory management Date: Thu, 19 Nov 2009 06:56:56 -0500 (EST) Message-ID: <20091119.065656.255106855.jeff@chaosphere.com> References: <20091118.075428.224836459.jeff@chaosphere.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1258632019 2784 80.91.229.12 (19 Nov 2009 12:00:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 19 Nov 2009 12:00:19 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Nov 19 13:00:12 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1NB5dD-0008G8-SA for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 12:57:00 +0100 Original-Received: from localhost ([127.0.0.1]:55191 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NB5dD-0006L2-7y for geh-help-gnu-emacs@m.gmane.org; Thu, 19 Nov 2009 06:56:59 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NB5cd-0006Km-Ti for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 06:56:23 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NB5cc-0006Ka-Sb for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 06:56:23 -0500 Original-Received: from [199.232.76.173] (port=35447 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NB5cc-0006KX-NA for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 06:56:22 -0500 Original-Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:42892) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NB5cc-0005MF-D6 for help-gnu-emacs@gnu.org; Thu, 19 Nov 2009 06:56:22 -0500 Original-Received: from localhost ([74.70.71.134]) by hrndva-omta01.mail.rr.com with ESMTP id <20091119115621332.VTWZ4786@hrndva-omta01.mail.rr.com> for ; Thu, 19 Nov 2009 11:56:21 +0000 In-Reply-To: X-Mailer: Mew version 6.3rc1 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (1203?) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:69915 Archived-At: From: Kevin Rodgers 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