[comp.lang.scheme] Self reference in objects

maeda@MCC.COM (Christopher Maeda) (10/20/88)

    From: HANCHE%NORUNIT.BITNET@CUNYVM.CUNY.EDU

    Date: 19 October 1988, 16:51:25 ECT
    From: Harald Hanche-Olsen       +47-7-593525         HANCHE   at NORUNIT
    To:   scheme@mc.lcs.mit.edu

    (I suppose this should be sent directly to Jonathan Dubman who asked
    the question, but my mailer would not accept his monstrous address...)

    To: apple!bionet!agate!e260-3b.berkeley.edu!128a-3aj@BLOOM-BEACON.MIT.EDU

    [...]

Wasn't there a 6.001 problem set on this?  Can't we just send the
sources to this guy and be done with it?

HANCHE@NORUNIT.BITNET (10/20/88)

Date: 19 October 1988, 16:51:25 ECT
From: Harald Hanche-Olsen       +47-7-593525         HANCHE   at NORUNIT
To:   scheme@mc.lcs.mit.edu

(I suppose this should be sent directly to Jonathan Dubman who asked
the question, but my mailer would not accept his monstrous address...)

To: apple!bionet!agate!e260-3b.berkeley.edu!128a-3aj@BLOOM-BEACON.MIT.EDU

Jonathan had problems with allowing his objects to refer to themselves.
His objects are defined by lambda expressions, so I can't think of any
reason why the following would not work:

(define (make-player ...)
  (letrec
    ((self (lambda (...)   <body of player>)))
    self))

or something like it.  In <body of player> you can use  self
to denote *this* player, like in

(present-room 'move self 'north)

- Harald Hanche-Olsen