help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Structured data in Emacs Lisp


From: Klaus Berndl
Subject: Re: Structured data in Emacs Lisp
Date: 27 Apr 2005 17:27:16 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

If you want to move around datas which belong together i recommend `defstruct'
which is in both Emacs and XEmacs available! It is a macro of the cl-package
so you can use it safely also with GNU Emacs ;-)

See the info-manual of `defstruct' - It#s in the cl-info-manual!

defstruct allows you to get and set slots via key-names so there are position
independed!


Does this help?
Klaus

On Tue, 26 Apr 2005, mailshield.gg@mailnull.com wrote:

>  I'm writing a moderately complex Emacs package and not being a Lisp
>  guru I  wonder what is the best way to handle data structures in
>  Elisp. The  emphasis is not on efficiency, rather on readability.
>  
>  For example, from a function I want to return three values. How should
>  I  do this?
>  
>  Using a list? (Value1 Value2 Value3)?
>  
>  This has the disadvantage of storing specific values on specific
>  positions, so the caller must now the first element of the list is
>  Value1,  etc. And what if the return value is changed later and Value2
>  is not  returned anymore? Then I have to fix every invocation of the
>  function.
>  
>  Or maybe an association list? '((value1 . 3) (value2 . 4) (value3 . 5))
>  It's certainly more resistant to code changes, but feels a bit
>  heavyweight. (Maybe its just me.)
>  
>  Or is there an other Lispish way to handle structured data I don't
>  know  about?

-- 
Klaus Berndl                    mailto: klaus.berndl@sdm.de
sd&m AG                         http://www.sdm.de
software design & management    
Carl-Wery-Str. 42, 81739 Muenchen, Germany
Tel +49 89 63812-392, Fax -220


reply via email to

[Prev in Thread] Current Thread [Next in Thread]