From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Decebal <CLDWesterhof@gmail.com>
Newsgroups: gmane.emacs.help
Subject: Re: Something like an array (list) of a class
Date: Mon, 13 Apr 2009 04:55:24 -0700 (PDT)
Organization: http://groups.google.com
Message-ID: <0b45eaa6-232b-4bc3-a505-d47910f6478d@37g2000yqp.googlegroups.com>
References: <665d0b7a-3230-4123-b9f4-2a645f44dd1c@a7g2000yqk.googlegroups.com>
	<mailman.5118.1239437738.31690.help-gnu-emacs@gnu.org>
	<9fe617de-13d8-4dbc-82f8-3cc575008e48@o18g2000vbi.googlegroups.com>
	<mailman.5186.1239523825.31690.help-gnu-emacs@gnu.org>
	<c918fd20-b8cb-4500-b2c6-6f0a973afcd9@c36g2000yqn.googlegroups.com>
NNTP-Posting-Host: lo.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1239626463 10306 80.91.229.12 (13 Apr 2009 12:41:03 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 13 Apr 2009 12:41:03 +0000 (UTC)
To: help-gnu-emacs@gnu.org
Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 13 14:42:22 2009
Return-path: <help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geh-help-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([199.232.76.165])
	by lo.gmane.org with esmtp (Exim 4.50)
	id 1LtLUQ-00086O-Fq
	for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Apr 2009 14:42:18 +0200
Original-Received: from localhost ([127.0.0.1]:59837 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1LtLSx-0001Hr-J4
	for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Apr 2009 08:40:47 -0400
Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!37g2000yqp.googlegroups.com!not-for-mail
Original-Newsgroups: gnu.emacs.help
Original-Lines: 40
Original-NNTP-Posting-Host: 84.53.123.169
Original-X-Trace: posting.google.com 1239623724 29482 127.0.0.1 (13 Apr 2009 11:55:24
	GMT)
Original-X-Complaints-To: groups-abuse@google.com
Original-NNTP-Posting-Date: Mon, 13 Apr 2009 11:55:24 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 37g2000yqp.googlegroups.com; posting-host=84.53.123.169; 
	posting-account=K-cdeAoAAAD_0d505kUtHXJaT5LFIu-3
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; nl; rv:1.9.0.8) 
	Gecko/2009032600 SUSE/3.0.8-1.1.1 Firefox/3.0.8,gzip(gfe),gzip(gfe)
Original-Xref: news.stanford.edu gnu.emacs.help:168426
X-BeenThere: help-gnu-emacs@gnu.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Users list for the GNU Emacs text editor <help-gnu-emacs.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/help-gnu-emacs>
List-Post: <mailto:help-gnu-emacs@gnu.org>
List-Help: <mailto:help-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
	<mailto:help-gnu-emacs-request@gnu.org?subject=subscribe>
Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.help:63704
Archived-At: <http://permalink.gmane.org/gmane.emacs.help/63704>

On 13 apr, 10:53, Decebal <CLDWester...@gmail.com> wrote:
> On Apr 12, 10:03=A0am, 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?