unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: Something like an array (list) of a class
Date: Mon, 13 Apr 2009 20:52:48 -0400	[thread overview]
Message-ID: <barmar-51D57B.20524813042009@mara100-84.onlink.net> (raw)
In-Reply-To: 67e696b0-bdf8-45e2-86d6-4a696bb2ecfa@r37g2000yqn.googlegroups.com

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 ***


  reply	other threads:[~2009-04-14  0:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-10 20:32 Something like an array (list) of a class Decebal
2009-04-11  8:08 ` thierry.volpiatto
     [not found] ` <mailman.5118.1239437738.31690.help-gnu-emacs@gnu.org>
2009-04-12  7:25   ` Decebal
2009-04-12  8:03     ` thierry.volpiatto
2009-04-12 16:15       ` Drew Adams
2009-04-12 17:15         ` thierry.volpiatto
2009-04-12 17:45           ` Drew Adams
     [not found]     ` <mailman.5186.1239523825.31690.help-gnu-emacs@gnu.org>
2009-04-13  8:53       ` Decebal
2009-04-13 11:55         ` Decebal
2009-04-13 12:27           ` Decebal
2009-04-13 14:56           ` Decebal
2009-04-13 17:57             ` Decebal
2009-04-14  0:52               ` Barry Margolin [this message]
2009-04-14  4:44                 ` Decebal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=barmar-51D57B.20524813042009@mara100-84.onlink.net \
    --to=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).