all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Johan Andersson <johan.rejeep@gmail.com>
To: "Pascal J. Bourguignon" <pjb@informatimago.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to describe something in Lisp?
Date: Tue, 3 Feb 2009 17:44:47 +0100	[thread overview]
Message-ID: <929ccd880902030844h77859033q9a1c359595a0ece2@mail.gmail.com> (raw)
In-Reply-To: <7cprhz3259.fsf@pbourguignon.anevia.com>

[-- Attachment #1: Type: text/plain, Size: 2015 bytes --]

Thanks all for your answers.

All of your examples will work fine in my case. But is it "accepted" by
Emacs users to code a mode using these structures? I've never seen them
before.

On Tue, Feb 3, 2009 at 5:40 PM, Pascal J. Bourguignon <pjb@informatimago.com
> wrote:

> Andreas Politz <politza@fh-trier.de> writes:
>
> > Johan Andersson wrote:
> >> Hi!
> >> As a Java and Ruby programmer I sometimes find it hard to code
> >> Lisp. Right
> >> now I'm working on a minor mode for which the structure would obvious
> for me
> >> in Java or Ruby, but in Lisp is a riddle.
> >> I will not describe the mode itself, but give a description of the
> >> problem.
> >> Say I want to store a list of people in a file. And for each person,
> also
> >> some information on them in the format:
> >> name|age|married|sex
> >> Each time I start the mode, that file should be parsed in to some
> >> datastructure (which kind of is the problem). And on save, the file
> would be
> >> updated. For me it's obvious to represent a person with a class:
> >> [...]
> >>  I read something about object orientation in lisp, but I have never
> >> seen this be used in Emacs. So my question is basically: What is the
> best
> >> way to model something in lisp, that you in an object oriented language
> >> would model with a class.
> >> Thanks!
> >
> > (defstruct person
> > [...]
>
> There is also EIEIO which is an implementation of CLOS, the Common
> Lisp Object System, adapted for emacs.
>
> You can find it part of http://cedet.sourceforge.net/
>
> Then you can define your objects:
>
> (require 'eieio)
>
> (defclass person
>  ((name       :type string :initarg :name      :accessor name)
>   (birthdate  :type date   :initarg :birthdate :accessor birthdate))
>   (status     :type marital-status :initarg  :martial-status :accessor
> martial-status)
>   (sex        :type (member :male :female) :initarg :sex :accessor sex))
>
> (defmethod age ((p person))
>  (date- (now) (birthdate p)))
>
> ...
>
> --
> __Pascal Bourguignon__
>

[-- Attachment #2: Type: text/html, Size: 2874 bytes --]

  reply	other threads:[~2009-02-03 16:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.6644.1233674526.26697.help-gnu-emacs@gnu.org>
2009-02-03 15:48 ` How to describe something in Lisp? Andreas Politz
2009-02-03 16:40   ` Pascal J. Bourguignon
2009-02-03 16:44     ` Johan Andersson [this message]
2009-02-03 16:54       ` Tassilo Horn
2009-02-03 17:07         ` Johan Andersson
2009-02-03 14:23 Johan Andersson
2009-02-03 16:24 ` Thierry Volpiatto
2009-02-03 16:46 ` Tassilo Horn
     [not found] ` <mailman.6652.1233679633.26697.help-gnu-emacs@gnu.org>
2009-02-04 10:33   ` Pascal J. Bourguignon
2009-02-04 11:43     ` Tassilo Horn
2009-02-05  2:28     ` Pascal J. Bourguignon
2009-02-05  7:22       ` Johan Andersson
     [not found]       ` <mailman.16.1233818553.17492.help-gnu-emacs@gnu.org>
2009-02-06 18:53         ` Ted Zlatanov
     [not found]   ` <7c63jq3319.fsf@pbourguignon.informatimago.com>
     [not found]     ` <mailman.6723.1233747843.26697.help-gnu-emacs@gnu.org>
2009-02-04 13:26       ` Pascal J. Bourguignon

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

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

  git send-email \
    --in-reply-to=929ccd880902030844h77859033q9a1c359595a0ece2@mail.gmail.com \
    --to=johan.rejeep@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pjb@informatimago.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.