From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: persistent lisp objects Date: Thu, 01 Oct 2009 10:14:24 +0200 Organization: ThierryVolpiatto Message-ID: <87ljjv5y5b.fsf@tux.homenetwork> References: <871vlqt9rv.fsf@tux.homenetwork> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1254385277 4797 80.91.229.12 (1 Oct 2009 08:21:17 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 1 Oct 2009 08:21:17 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 01 10:21:10 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MtGuR-0000ks-UL for ged-emacs-devel@m.gmane.org; Thu, 01 Oct 2009 10:21:08 +0200 Original-Received: from localhost ([127.0.0.1]:37516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtGuR-0001xV-CT for ged-emacs-devel@m.gmane.org; Thu, 01 Oct 2009 04:21:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MtGuI-0001wm-SO for emacs-devel@gnu.org; Thu, 01 Oct 2009 04:20:58 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MtGuD-0001uy-Rf for emacs-devel@gnu.org; Thu, 01 Oct 2009 04:20:57 -0400 Original-Received: from [199.232.76.173] (port=45857 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MtGuD-0001us-8l for emacs-devel@gnu.org; Thu, 01 Oct 2009 04:20:53 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:45077) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MtGuC-0000TM-OS for emacs-devel@gnu.org; Thu, 01 Oct 2009 04:20:52 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1MtGu8-0000fh-TB for emacs-devel@gnu.org; Thu, 01 Oct 2009 10:20:48 +0200 Original-Received: from 195.77.197-77.rev.gaoland.net ([77.197.77.195]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Oct 2009 10:20:48 +0200 Original-Received: from thierry.volpiatto by 195.77.197-77.rev.gaoland.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Oct 2009 10:20:48 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 195.77.197-77.rev.gaoland.net Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEUHAwNfJRBVTESlTym0 RB/OwKFivhZqAAAACXBIWXMAAAsSAAALEgHS3X78AAAACXZwQWcAAAAwAAAAMADO7oxXAAABeElE QVQ4y3VTW47CMAyMwwUyTfYfUvG/wfC/ET4B0t7/KmsHurRgXFVVPRm/xglhsRj2+npW98G3+Amp tS5BXxl3SqzcXGRuEyf7n5lPA9jXetNPRhE7EJkzfz8YWnIgBSwW95TK4H79/t4GINKNADWj4PgA DiJX/ZxFDzDXeb4oYMw7kNUvyMzcaj3ioICG4hCKEShkPpwQ49Q05nnkGAQLDFDdExjm0qpowBYA Wi61bDlFU1GW0WbY2dSJYX5ZD2S0AiZL+rPyE19TpMzP2IvNWly+NkuWNgD4pO2oL73IQXoSyVX2 NHna7tgadWRXoCdvf2guqEcvGHqZwE520iRD0/QCYiiTE+U21w1Qxvg6iSp9fbIiDCnSAelDkCVF Vn+HekqXzRybwJ40xF4DMRG6SWGK9G1lYzHSxLYEm05GWbpJCB6A9tb9A3BGn2XdwJbS/WuInj74 4QNF8sVFdP3vl+5tgYp4Ev7fyrfFMkXgElDgV4uV/w8TWEeLCIGJ/AAAACV0RVh0Y3JlYXRlLWRh dGUAMjAwOC0wNS0zMVQyMjoxNDoyMiswMjowMM7uH/IAAAARdEVYdGpwZWc6Y29sb3JzcGFjZQAy LHVVnwAAACB0RVh0anBlZzpzYW1wbGluZy1mYWN0b3IAMngyLDF4MSwxeDFJ+qa0AAAAJXRFWHRt b2RpZnktZGF0ZQAyMDA3LTEwLTI4VDE3OjA4OjQ4KzAxOjAwhqNSRgAAAABJRU5ErkJggg== User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:q3J+fASCrJwurMtKVZNOIEkrWAc= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115821 Archived-At: Thierry Volpiatto writes: > Hi all, > it seem using `setf' combined with `eval-when-compile' is a convenient > way to save lisp object like hash-table. > It is not documented. > What do you think? Maybe i was not clear enough. We can actually save any lisp object in a compiled file: ,---- | (defun tv-dump-object-to-file (obj file) | "Save symbol object `obj' to the byte compiled version of `file'. | `obj' can be any lisp object, list, hash-table, etc... | `file' is an elisp file with ext *.el. | Loading the *.elc file will restitute object." | (require 'cl) ; Be sure we use the CL version of `eval-when-compile'. | (if (file-exists-p file) | (error "File already exists.") | (with-temp-file file | (erase-buffer) | (let* ((str-obj (symbol-name obj)) | (fmt-obj (format "(setq %s (eval-when-compile %s))" str-obj str-obj))) | (insert fmt-obj))) | (byte-compile-file file) (delete-file file) | (message "`%s' dumped to %sc" obj file))) `---- This is a feature of `eval-when-compile' that is not documented. It can be interesting as AFAIK there is no way to save object. -- A + Thierry Volpiatto Location: Saint-Cyr-Sur-Mer - France