Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!swrinde!pipex!uunet!newsflash.concordia.ca!CC.UMontreal.CA!beryl!surprenc
From: surprenc@JSP.UMontreal.CA (Surprenant Colin)
Subject: Re: Choice of OOP for Scheme
Message-ID: <D2xGFv.19E@cc.umontreal.ca>
Sender: news@cc.umontreal.ca (Administration de Cnews)
Organization: Universite de Montreal
X-Newsreader: TIN [version 1.2 PL2]
References: <philo-2301951744090001@mac-h164e.cogsci.ed.ac.uk> <DMEGGINS.95Jan23152149@aix1.uottawa.ca>
Date: Tue, 24 Jan 1995 20:47:53 GMT
Lines: 73

David Megginson (dmeggins@aix1.uottawa.ca) wrote:
: I am also interested in a simple OO system for scheme -- the ones I've
: looked at seem somewhat obfuscated.  It would be nice simply to enter
: something like

: (class foo
:   (inherit class bar)
:   (variable (hack 3))
:   (method (set-hack! value) (set! hack 3))
:   (method (get-hack!) hack))

: and

: (define x (foo new))

: to create an instance of the class `foo', and then use operations like

: (x get-hack)             ==> 3
: (x set-hack! 25)
: (x get-hack)             ==> 25

I have been using Meroon V3 with the SCM interpreter from MIT. 
It is the only one I used, so I can't compare it to other object systems.

Meroon seems very efficient, and is quite versatile and powerfull.

let's look at how we could implement your example with Meroon:


(define-class foo bar (hack))

(define-generic (set-hack! (o foo) value))
(define-generic (get-hack (o foo)))       

(define-method (set-hack! (o foo) value)
  (set-foo-hack! o value))

(define-method (get-hack (o foo))
  (foo-hack o))


(define x (make-foo 3))
(get-hack x)                  ==> 3
(set-hack! x 1)
(get-hack x)                  ==> 1


1- It would have been possible to get rid of the methods and have their
   bodys directly in the generics. Usually you have a generic with a
   default body, and the methods as specializations.

2- You can have automatic initializers for the variables in the class 
   definition.


Here's an excerpt of the Meroon abstract:
<<Distinctive features of Meroon V3 are indexed fields without inheritace
  restriction, code-generating meta-classes and an instantiation protocol
  that respects immutability. Meroon V3 also supports multimethods, coercers,
  generic equality, metaclasses but not multiple inheritance.>>

Meroon's author is Christian Queinnec: queinnec@polytechnique.fr

you can find Meroon at:

ftp.inria.fr:INRIA/Projects/icsla/Programs
nexus.yorku.ca:pub/Scheme

--

| Colin Surprenant  | colin@connex.interlink.net |
| 514-849-0948      | -------------------------- |
| Montreal, Quebec  | surprenc@jsp.umontreal.ca  |
