[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Self reference in objects
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