[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Structured data in Emacs Lisp
From: |
Phillip Lord |
Subject: |
Re: Structured data in Emacs Lisp |
Date: |
26 Apr 2005 17:03:45 +0100 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 |
>>>>> "PT" == PT <mailshield.gg@mailnull.com> writes:
PT> I'm writing a moderately complex Emacs package and not being a
PT> Lisp guru I wonder what is the best way to handle data
PT> structures in Elisp. The emphasis is not on efficiency, rather
PT> on readability.
PT> For example, from a function I want to return three values. How
PT> should I do this?
PT> Using a list? (Value1 Value2 Value3)?
PT> This has the disadvantage of storing specific values on specific
PT> positions, so the caller must now the first element of the list
PT> is Value1, etc. And what if the return value is changed later
PT> and Value2 is not returned anymore? Then I have to fix every
PT> invocation of the function.
PT> Or maybe an association list? '((value1 . 3) (value2 . 4)
PT> (value3 . 5)) It's certainly more resistant to code changes, but
PT> feels a bit heavyweight. (Maybe its just me.)
PT> Or is there an other Lispish way to handle structured data I
PT> don't know about?
plists, or a hashtable would also work.
Another solution would be to look at eieio, which gives you objects
that you can then pass around. This doesn't directly answer your
question, but it gets away from some of the nastiness of having
multiply nested list structures.
Phil