unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to describe something in Lisp?
@ 2009-02-03 14:23 Johan Andersson
  2009-02-03 16:24 ` Thierry Volpiatto
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Johan Andersson @ 2009-02-03 14:23 UTC (permalink / raw)
  To: help-gnu-emacs

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

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:
class Person
  var name, age, married, sex

  methods...
end

Then I could easy update attributes on the objects, remove and add people
and then update the file.

I tried with a couple of solutions for this in Lisp:

1) One list named people:
(
  (name age married sex)
  ...
)

2) Multiple lists named name, age, married and sex where the index decides
the connection between the lists:
(name1 name2)
(age1 age2)
(married1 married2)
(sex1 sex2)

3) Same as two, but with arrays:
[name1 name2]
[age1 age2]
[married1 married2]
[sex1 sex2]


Each way above has their disadvantages and I think none of them is good
enough. 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!

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

^ permalink raw reply	[flat|nested] 14+ messages in thread
[parent not found: <mailman.6644.1233674526.26697.help-gnu-emacs@gnu.org>]

end of thread, other threads:[~2009-02-06 18:53 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-03 14:23 How to describe something in Lisp? 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
     [not found] <mailman.6644.1233674526.26697.help-gnu-emacs@gnu.org>
2009-02-03 15:48 ` Andreas Politz
2009-02-03 16:40   ` Pascal J. Bourguignon
2009-02-03 16:44     ` Johan Andersson
2009-02-03 16:54       ` Tassilo Horn
2009-02-03 17:07         ` Johan Andersson

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).