[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Something like an array (list) of a class
From: |
Decebal |
Subject: |
Re: Something like an array (list) of a class |
Date: |
Mon, 13 Apr 2009 04:55:24 -0700 (PDT) |
User-agent: |
G2/1.0 |
On 13 apr, 10:53, Decebal <CLDWester...@gmail.com> wrote:
> On Apr 12, 10:03 am, thierry.volpia...@gmail.com wrote:
>
> > There is no class in elisp but you have defstruct (be sure to require 'cl)
>
> Looks like it that it does what I want. I want only the last field
> mutable and the other fields parameterized. That is possible if I
> understand it correctly.
I tried the following:
(require 'cl)
(defstruct
(ModeLine
(:constructor nil)
(:constructor new-ModeLine (type description display function))
)
(type :read-only t)
(description :read-only t)
(display :read-only t)
(function :read-only t)
)
(setq e (new-ModeLine
"word"
"Display number of words"
"W"
'buffer-count-words
)
)
This seems to do what I want.
A few questions remain:
- Is there a way to make sure that type, description and display are
of type string and function of type function?
- Is there a way to make sure that none of the elements are empty?
- I would like to have a list (or other data structure) filled with
only objects of type ModeLine. What is the best way to do this?
- Is it possible to have all type and display values distinct?
- Something like an array (list) of a class, Decebal, 2009/04/10
- Message not available
- Re: Something like an array (list) of a class, Decebal, 2009/04/13
- Re: Something like an array (list) of a class,
Decebal <=
- Re: Something like an array (list) of a class, Decebal, 2009/04/13
- Re: Something like an array (list) of a class, Decebal, 2009/04/13
- Re: Something like an array (list) of a class, Decebal, 2009/04/13
- Re: Something like an array (list) of a class, Barry Margolin, 2009/04/13
- Re: Something like an array (list) of a class, Decebal, 2009/04/14