Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!think.com!snorkelwacker.mit.edu!ai-lab!zurich.ai.mit.edu!markf From: markf@zurich.ai.mit.edu (Mark Friedman) Newsgroups: comp.lang.scheme Subject: Re: Simulating Environments with Continuations ? Message-ID: Date: 27 Jun 91 22:25:28 GMT References: <1991Jun27.192117.8609@jato.jpl.nasa.gov> Sender: news@ai.mit.edu Reply-To: markf@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 45 In-reply-to: brian@granite.jpl.nasa.gov's message of 27 Jun 91 19:21:17 GMT In article <1991Jun27.192117.8609@jato.jpl.nasa.gov> brian@granite.jpl.nasa.gov (Brian of ASTD-CP) writes: (define ( [args]) (let (( ) ( ) ...) (define ( ) ; reference ivars as free vars ) (define ( ) ; reference ivars as free vars ) ... (define (self msg [args]) (case msg (msg1 ) (msg2 ) ...)) self)) To instantiate an object (instance of a class), call the cons- tructor. The instance is represented by the message dispatch procedure ("self") returned. All the methods have access to the instance vars _via_ lexical scoping. Ok, the only problem is that each instance of a class will have its own copy of the method procedures. This is wasteful of space, since all the copies of each method proc are identical, having been "define"d by the same source code. What we want to do is solve the problem through method sharing. Unless your interpreter is going out of its way to be wasteful and silly (and unless it was careful it would be incorrect for the most general case) the above approach will not copy the method-proc's in each instance. Each instance (a closure) will have a pointer to the environment which contains the method-procs. -Mark -- Mark Friedman MIT Artificial Intelligence Lab 545 Technology Sq. Cambridge, Ma. 02139 markf@zurich.ai.mit.edu