From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: How to describe something in Lisp? Date: Tue, 03 Feb 2009 17:40:02 +0100 Organization: Anevia SAS Message-ID: <7cprhz3259.fsf@pbourguignon.anevia.com> References: <1233676167.44903@arno.fh-trier.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1233679363 20604 80.91.229.12 (3 Feb 2009 16:42:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 Feb 2009 16:42: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 Feb 03 17:43:58 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 1LUONE-0002TZ-Cw for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Feb 2009 17:43:44 +0100 Original-Received: from localhost ([127.0.0.1]:47937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LUOLv-00086W-MM for geh-help-gnu-emacs@m.gmane.org; Tue, 03 Feb 2009 11:42:23 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news.cs.univ-paris8.fr!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp8-1.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:by+eYci3yDtQiblDKwc4BV/vCw8= Original-Lines: 48 Original-NNTP-Posting-Date: 03 Feb 2009 17:40:02 MET Original-NNTP-Posting-Host: 88.170.236.224 Original-X-Trace: 1233679202 news-2.free.fr 3503 88.170.236.224:44117 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:166568 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:61882 Archived-At: Andreas Politz 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__