From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Toby Cubitt Newsgroups: gmane.emacs.help Subject: Re: Writing a function/macro in Elisp that generates a function at runtime Date: Tue, 28 Oct 2008 18:10:10 +0100 Message-ID: <49074772.6050307@dr-qubit.org> References: <4906EB9C.10501@dr-qubit.org> <86fxmg4qfh.fsf@lifelogs.com> Reply-To: Toby Cubitt NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1225217572 4858 80.91.229.12 (28 Oct 2008 18:12:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 28 Oct 2008 18:12:52 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 28 19:13:54 2008 connect(): Connection refused 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 1Kut42-0003vG-Ac for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2008 19:13:10 +0100 Original-Received: from localhost ([127.0.0.1]:41092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kut2v-000352-Ru for geh-help-gnu-emacs@m.gmane.org; Tue, 28 Oct 2008 14:12:01 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Kut1s-00024y-Sc for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:10:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Kut1q-00020m-0R for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:10:56 -0400 Original-Received: from [199.232.76.173] (port=55457 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Kut1p-00020X-Rn for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:10:53 -0400 Original-Received: from mail.geekisp.com ([216.168.135.169]:3566 helo=starfish.geekisp.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Kut1p-0004qj-Dt for help-gnu-emacs@gnu.org; Tue, 28 Oct 2008 14:10:53 -0400 Original-Received: (qmail 21936 invoked by uid 1003); 28 Oct 2008 18:10:15 -0000 Original-Received: from [192.168.1.11] (localhost.geekisp.com [127.0.0.1]) by localhost.geekisp.com (tmda-ofmipd) with ESMTP; Tue, 28 Oct 2008 14:10:12 -0400 User-Agent: Thunderbird 2.0.0.17 (X11/20080929) In-Reply-To: <86fxmg4qfh.fsf@lifelogs.com> X-Delivery-Agent: TMDA/1.1.11 (Ladyburn) X-Primary-Address: toby@dr-qubit.org X-detected-operating-system: by monty-python.gnu.org: OpenBSD 3.0-3.9 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:59212 Archived-At: Hi Ted, Thanks for taking the time to reply. Ted Zlatanov wrote: > On Tue, 28 Oct 2008 13:42:57 +0100 Toby Cubitt wrote: > > TC> I have a higher-level data structure built on top of a lower-level one. > TC> Internally, the higher-level structure stores data "cells" in the > TC> lower-level structure. The lower-level structure of course knows nothing > TC> about this. It just stores any kind of data, without knowing anything > TC> about its structure. And users of the higher-level structure also know > TC> nothing about the data cells, which are part of the internal > TC> implementation. As far as users are concerned, they can just store data > TC> of whatever kind they like in the higher-level structure. [snip] > I don't understand why you're trying to cross between the storage and > the logic (essentially, that's what your "low level" and "high level" > layers are). The logic layer should know how to convert its data to and > from a neutral data format (in Lisp, that's usually a list). The > storage layer should just store and retrieve the neutral data format. It's difficult to motivate it whilst trying to avoid explaining the entire code :) I don't really want to get into a discussion here about general design issues, since it's not appropriate to this list. The trouble is, it's difficult to explain why I can't just use the simple solution proposed by Barry Margolin without explaining a bit of the background. I'm not too sure what you mean by "logic layer", but I'm not doing anything as complicated as that sounds. The data structures are just that: data structures (they're a kind of tree, with some extra gubbins on top), along with a bunch of functions for using them. (In OOP these "higher-level" and "lower-level" data structures would be two different classes, the functions would be class methods, and the "high-level" class would contain an instance of the "low-level" one. The 'has-a' relationship, i.e. one containing the other, is the reason I was calling them "higher-level" and "lower-level", nothing more complicated than that.) > Your approach makes sense, IMO, in an OOP environment where every object > knows how to serialize itself. Off-topic, one thing I love about Lisp is that it's so easy to take the good parts of OOP and use them directly, without any of the OOP complexity and mess. The good bits are already there as soon as functions are first-class objects!.....Any replies to these comments should be directed off-list, though :) > I got the following from > http://dorophone.blogspot.com/ and it may help you to sort-of-do > serializable objects if that's your goal... You just print the value of > each object you create, and later you can eval them back in. Interesting, but this is certainly overkill for what I'm doing. Toby