[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Something like an array (list) of a class
From: |
Barry Margolin |
Subject: |
Re: Something like an array (list) of a class |
Date: |
Mon, 13 Apr 2009 20:52:48 -0400 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article
<67e696b0-bdf8-45e2-86d6-4a696bb2ecfa@r37g2000yqn.googlegroups.com>,
Decebal <CLDWesterhof@gmail.com> wrote:
> I know have:
> (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 modelineArray
> [
> (new-ModeLine
> "chars"
> "Display number of chars"
> "C"
> 'buffer-count-chars2
> )
> (new-ModeLine
> "lines"
> "Display number of lines"
> "L"
> 'buffer-count-lines2
> )
> (new-ModeLine
> "words"
> "Display number of words"
> "W"
> 'buffer-count-words2
> )
> ]
> )
>
> But there are a few problems:
> - I would like to have the vector modelineArray readonly. Is this
> possible?
The syntax of a slot specification is
(slot-name default options...)
In your defstruct, you specified :read-only as the default, so it's not
being taken as an option name. Try:
(type nil :read-only t)
> - The vector is notfilled with ModeLine objects. When executing:
> (aref modelineArray 2)
> I get:
> (new-ModeLine "words" "Display number of words" "W" (quote buffer-
> count-words2))
> So I can not do something like:
> (ModeLine-type (aref modelineArray 2))
> What is the good way to fill the vector?
[...] is for literals, it doesn't evaluate its contents. Use (vector
...) instead.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
- Re: Something like an array (list) of a class, (continued)
- Message not available
- Re: Something like an array (list) of a class, Decebal, 2009/04/12
- Re: Something like an array (list) of a class, thierry . volpiatto, 2009/04/12
- RE: Something like an array (list) of a class, Drew Adams, 2009/04/12
- Re: Something like an array (list) of a class, thierry . volpiatto, 2009/04/12
- RE: Something like an array (list) of a class, Drew Adams, 2009/04/12
- 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, 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, Decebal, 2009/04/13
- Re: Something like an array (list) of a class,
Barry Margolin <=
- Re: Something like an array (list) of a class, Decebal, 2009/04/14