From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: One more question about elisp Date: Fri, 6 Nov 2009 12:02:23 -0800 (PST) Organization: http://groups.google.com Message-ID: 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 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1257584742 12210 80.91.229.12 (7 Nov 2009 09:05:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 7 Nov 2009 09:05:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Nov 07 10:05:35 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 1N6hEj-0004yN-Qw for geh-help-gnu-emacs@m.gmane.org; Sat, 07 Nov 2009 10:05:34 +0100 Original-Received: from localhost ([127.0.0.1]:50312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N6hEj-0004qO-F7 for geh-help-gnu-emacs@m.gmane.org; Sat, 07 Nov 2009 04:05:33 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!y10g2000prg.googlegroups.com!not-for-mail Original-Newsgroups: comp.emacs,gnu.emacs.help Original-Lines: 42 Original-NNTP-Posting-Host: 76.102.12.87 Original-X-Trace: posting.google.com 1257537743 32745 127.0.0.1 (6 Nov 2009 20:02:23 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 6 Nov 2009 20:02:23 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y10g2000prg.googlegroups.com; posting-host=76.102.12.87; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.27 Safari/532.0, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu comp.emacs:99396 gnu.emacs.help:174484 X-Mailman-Approved-At: Sat, 07 Nov 2009 04:04:51 -0500 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:69574 Archived-At: On Nov 6, 8:46 am, Francis Moreau wrote: > Hello, > > I'm now wondering what is the elisp way to create structured objects > and how to access them later. > > For example I want to create a structure/object which store > information about a person. > > In C language, I would do something like this: > > structure person { > int age; > char *name; > > }; > > For an object oriented language, Python for example, I would do: > > class Person(object): > def __init__(self, age, name): > self.age =3D age > self.name =3D name > > but how I do that in elisp ? > > Should I use a list ? That wouldn't be convenient for accessing the > 'fields' of the object later since I need to use an index rather than > a name field. > > Could anybody provide a pointer or any hints ? you can use Association Lists or hash table. For a short tutorial, see: =E2=80=A2 Elisp Lesson: Hash Table http://xahlee.org/emacs/elisp_hash_table.html Xah =E2=88=91 http://xahlee.org/ =E2=98=84