From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Johan Andersson Newsgroups: gmane.emacs.help Subject: How to describe something in Lisp? Date: Tue, 3 Feb 2009 15:23:10 +0100 Message-ID: <929ccd880902030623t1ccb3567weecce35deb378f73@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=0015174c14183046970462046958 X-Trace: ger.gmane.org 1233674629 2552 80.91.229.12 (3 Feb 2009 15:23:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Feb 2009 15:23:49 +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 Feb 03 16:25:04 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 1LUN8v-00047u-HO for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Feb 2009 16:24:53 +0100 Original-Received: from localhost ([127.0.0.1]:55890 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUN7b-0006J0-NF for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Feb 2009 10:23:31 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LUMBK-0002J8-KB for help-gnu-emacs@gnu.org; Tue, 03 Feb 2009 09:23:18 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LUMBJ-0002Il-2T for help-gnu-emacs@gnu.org; Tue, 03 Feb 2009 09:23:18 -0500 Original-Received: from [199.232.76.173] (port=36077 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUMBI-0002Ih-QH for help-gnu-emacs@gnu.org; Tue, 03 Feb 2009 09:23:16 -0500 Original-Received: from nf-out-0910.google.com ([64.233.182.188]:61693) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LUMBF-0005sq-RR for help-gnu-emacs@gnu.org; Tue, 03 Feb 2009 09:23:14 -0500 Original-Received: by nf-out-0910.google.com with SMTP id c7so375165nfi.26 for ; Tue, 03 Feb 2009 06:23:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=wP7ZIRvTd/Wm6qRupoCCDvN2G+9iE+DragIP6evETAk=; b=vSm7WMi3ZK00BNv8w7FTHim+cQOzKWlTci16qFccHBe27WSPyO1Ft8/nDAx229k7ga sShxvYy5WgUDsrZwd4HTujwc/of847CYhZqqZ4Elax6X6ZzZ/OjffDttoo+L4WHBYGzr YjBz0yIueOyCCkz/fm6fxjW/KWcieBL8LjNZ0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=qPW3Qee9DwU9EEGcTDeT/QhjI2DkxL+dMqs5LJ/uh4FIKq3DKVSSglMvHZTBpq+VQb IKErXwpdnNhEXCSsSymDwlRrXJqYGjYP73se1anUlv+xnhyI/kzTYfMFC6qB9WG0symb XFIGUnJB/TioJdYDRVel30/pOKuNCkgdH5Ip8= Original-Received: by 10.210.92.8 with SMTP id p8mr766003ebb.6.1233670991004; Tue, 03 Feb 2009 06:23:11 -0800 (PST) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-Mailman-Approved-At: Tue, 03 Feb 2009 10:22:04 -0500 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:61875 Archived-At: --0015174c14183046970462046958 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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! --0015174c14183046970462046958 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi!

As a Java and Ruby programmer I sometimes find it hard to code L= isp. Right now I'm working on a minor mode for which the structure woul= d obvious for me in Java or Ruby, but in Lisp is a riddle.

I will no= t describe the mode itself, but give a description of the problem. Say I wa= nt to store a list of people in a file. And for each person, also some info= rmation 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 sav= e, 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 a= nd add people and then update the file.

I tried with a couple of sol= utions for this in Lisp:

1) One list named people:
(
  (name age married sex)
&nb= sp; ...
)

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

3) Same as two, but with arrays:<= br>[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 languag= e would model with a class.

Thanks!
--0015174c14183046970462046958--