From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tomas@tuxteam.de Newsgroups: gmane.emacs.help Subject: Re: One more question about elisp Date: Sun, 8 Nov 2009 10:53:43 +0100 Message-ID: <20091108095343.GB17095@tomas> References: <53781544-57b8-4cde-a07a-c3632d8bac7f@a32g2000yqm.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1257674565 1134 80.91.229.12 (8 Nov 2009 10:02:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 8 Nov 2009 10:02:45 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Francis Moreau Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 08 11:02:37 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 1N74bV-0001Rp-ER for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Nov 2009 11:02:37 +0100 Original-Received: from localhost ([127.0.0.1]:45684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N74bV-0001Lr-0t for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Nov 2009 05:02:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N74b3-0001JM-Ic for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 05:02:09 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N74ax-0001Fb-Q5 for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 05:02:08 -0500 Original-Received: from [199.232.76.173] (port=46599 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N74ax-0001FY-Mz for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 05:02:03 -0500 Original-Received: from alextrapp1.equinoxe.de ([217.22.192.104]:60697 helo=www.elogos.de) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N74ax-0002cK-2A for help-gnu-emacs@gnu.org; Sun, 08 Nov 2009 05:02:03 -0500 Original-Received: by www.elogos.de (Postfix, from userid 1000) id 2404F90048; Sun, 8 Nov 2009 10:53:43 +0100 (CET) Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.15+20070412 (2007-04-11) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:69598 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sat, Nov 07, 2009 at 06:41:07AM -0800, Francis Moreau wrote: > On 7 nov, 02:40, LanX wrote: > > On 6 Nov., 22:05, Francis Moreau wrote: > > > > > It sounds strange to me (knowing C, python) to use hash tables to > > > structure data. > > > > You never used dicts in python for structured data??? >=20 > No since python is known to be an object oriented language, if I want > to create an object, I'm defining a new class. I don't use a hash > table for that. But Python *does* anyway use a hash behind the scenes for that. Like Perl and friends (as you seem to know, see below). >=20 > C allows to define new type. So I won't use a hash table to do that. >=20 > But I can understand that elisp has no way to create new types, and > hash tables can serve the purpose although I'm wondering how the code > will be readable (yes I already found elisp quite hard to read). You have been pointed to "defstruct" already. From it info page: +--------------------------------------------------------------------- | defstruct is an autoloaded Lisp macro in `cl-macs.el'. |=20 | (defstruct (name options...) (slot slot-opts...)...) |=20 | Define a struct type. | This macro defines a new Lisp data type called name, which contains da= ta | stored in slots. This defines a `make-name' constructor, a `copy-name= ' | copier, a `name-p' predicate, and setf-able `NAME-SLOT' accessors. +--------------------------------------------------------------------- > > IIRC an object instance =C2=A0(like in your example) is actually just= a > > dictionary and "dictionary" is just the python way to say hash table. >=20 > That's an implementation detail. The way you access fields of an > object through a hash table doesn't mean that an object is equivalent > to a hash table. If you don't care in Python, why you should care in Lisp? Just define a couple of accessor macros and be done with it. Or let Lisp do it for you, via a clever set of macros, als cl-macs.el does for you :-) Regards - -- tom=C3=A1s -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFK9pUnBcgs9XrR2kYRAoWaAJ0VtHsdLiDEFGsvN6Z+WfbOs9/91gCfczPg tL0/3pI9YbQx+jpVoIP51gw=3D =3DaYy7 -----END PGP SIGNATURE-----