[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: One more question about elisp
From: |
Xah Lee |
Subject: |
Re: One more question about elisp |
Date: |
Fri, 6 Nov 2009 12:02:23 -0800 (PST) |
User-agent: |
G2/1.0 |
On Nov 6, 8:46 am, Francis Moreau <francis.m...@gmail.com> 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 = age
> self.name = 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:
• Elisp Lesson: Hash Table
http://xahlee.org/emacs/elisp_hash_table.html
Xah
∑ http://xahlee.org/
☄
- One more question about elisp, Francis Moreau, 2009/11/06
- Re: One more question about elisp, Joost Kremers, 2009/11/06
- Re: One more question about elisp, Francis Moreau, 2009/11/06
- Re: One more question about elisp, Pascal J. Bourguignon, 2009/11/06
- Re: One more question about elisp, Stefan Monnier, 2009/11/06
- Re: One more question about elisp, Francis Moreau, 2009/11/08
- Re: One more question about elisp, Pascal J. Bourguignon, 2009/11/08
- Re: One more question about elisp, Francis Moreau, 2009/11/09
- Re: One more question about elisp, Stefan Monnier, 2009/11/08
Re: One more question about elisp,
Xah Lee <=
- Re: One more question about elisp, Francis Moreau, 2009/11/06
- Re: One more question about elisp, David Kastrup, 2009/11/06
- Re: One more question about elisp, LanX, 2009/11/06
- Re: One more question about elisp, Barry Margolin, 2009/11/06
- Re: One more question about elisp, Francis Moreau, 2009/11/07
- Re: One more question about elisp, Pascal J. Bourguignon, 2009/11/07
- Re: One more question about elisp, LanX, 2009/11/07
- Re: One more question about elisp, tomas, 2009/11/08
- Message not available
- Re: One more question about elisp, Francis Moreau, 2009/11/08
- Re: One more question about elisp, Pascal J. Bourguignon, 2009/11/08