From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Something like an array (list) of a class Date: Mon, 13 Apr 2009 20:52:48 -0400 Organization: A noiseless patient Spider Message-ID: References: <665d0b7a-3230-4123-b9f4-2a645f44dd1c@a7g2000yqk.googlegroups.com> <9fe617de-13d8-4dbc-82f8-3cc575008e48@o18g2000vbi.googlegroups.com> <0b45eaa6-232b-4bc3-a505-d47910f6478d@37g2000yqp.googlegroups.com> <97cb2f72-c82d-4143-9842-07240924b517@f19g2000yqo.googlegroups.com> <67e696b0-bdf8-45e2-86d6-4a696bb2ecfa@r37g2000yqn.googlegroups.com> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1239673243 23139 80.91.229.12 (14 Apr 2009 01:40:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 Apr 2009 01:40:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Apr 14 03:42:03 2009 Return-path: 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 1LtXf0-0003tW-CG for geh-help-gnu-emacs@m.gmane.org; Tue, 14 Apr 2009 03:42:02 +0200 Original-Received: from localhost ([127.0.0.1]:36701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LtXdb-0001mY-SN for geh-help-gnu-emacs@m.gmane.org; Mon, 13 Apr 2009 21:40:35 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!motzarella.org!feeder.motzarella.org!news.motzarella.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 72 Original-X-Trace: news.eternal-september.org U2FsdGVkX1/hptg145pzXxvTn2JjHSLa9tXJY/kSlxIEo+dDQR2qXGZQIp1af+BzJmIQEauO2z1gR/iOkw/hn+O6dK6hGPYmPNkZMqaAV2Kj3NmkJrjB0DSdRhJP4/TMXuJPCGajXuyaIulc5svcQw== Original-X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers Original-NNTP-Posting-Date: Tue, 14 Apr 2009 00:52:18 +0000 (UTC) X-Auth-Sender: U2FsdGVkX19Pzm8s3tSO7OiA1SaTz6QsuGJKMj7UzZo= Cancel-Lock: sha1:lAugp4i4u3ha77//IzKfbMl9eM8= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Mail-Copies-To: nobody Original-Xref: news.stanford.edu gnu.emacs.help:168441 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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:63718 Archived-At: In article <67e696b0-bdf8-45e2-86d6-4a696bb2ecfa@r37g2000yqn.googlegroups.com>, Decebal 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 ***