Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!ucbvax!hplabs!hplabsz!mayer From: mayer@hplabsz.HPL.HP.COM (Niels Mayer) Newsgroups: comp.lang.lisp.x Subject: Re: A few questions from a hacker. Message-ID: <5854@hplabsz.HPL.HP.COM> Date: 27 Aug 90 20:20:58 GMT References: <1990Aug27.001721.9563@comp.vuw.ac.nz> Reply-To: mayer@hplabs.hp.com (Niels Mayer) Organization: Hewlett-Packard Labs, Software & Systems Lab, Palo Alto, CA. Lines: 95 Summary: Expires: Sender: Followup-To: In article <1990Aug27.001721.9563@comp.vuw.ac.nz> L.Parkes@comp.vuw.ac.nz (Lloyd Parkes) writes: > 2) Why doesn't xlobget/setvalue search the ivars of the object > being sent the message, when looking for local bindings of > symbols? It does... Through the miracle of gnuemacs tags (M-.) , I traced out the following sequence of calls in xlisp 2.1: (eval...)-->xleval()-->xlgetvalue()-->xlxgetvalue()-->xlobgetvalue(): [from xlsym.c] |/* xlxgetvalue - get the value of a symbol */ |LVAL xlxgetvalue(sym) | LVAL sym; |{ | register LVAL fp,ep; | LVAL val; | | /* check the environment list */ | for (fp = xlenv; fp; fp = cdr(fp)) | | /* check for an instance variable */ + if ((ep = car(fp)) && objectp(car(ep))) { + if (xlobgetvalue(ep,sym,&val)) + return (val); | } | | /* check an environment stack frame */ | else { | for (; ep; ep = cdr(ep)) | if (sym == car(car(ep))) | return (cdr(car(ep))); | } | | /* return the global value */ | return (getvalue(sym)); |} [from xlobj.c] |/* xlobgetvalue - get the value of an instance variable */ |int xlobgetvalue(pair,sym,pval) | LVAL pair,sym,*pval; |{ | LVAL cls,names; | int ivtotal,n; | | /* find the instance or class variable */ | for (cls = cdr(pair); objectp(cls); cls = getivar(cls,SUPERCLASS)) { | | /* check the instance variables */ | names = getivar(cls,IVARS); | ivtotal = getivcnt(cls,IVARTOTAL); | for (n = ivtotal - getivcnt(cls,IVARCNT); n < ivtotal; ++n) { | if (car(names) == sym) { | *pval = getivar(car(pair),n); | return (TRUE); | } | names = cdr(names); | } | | /* check the class variables */ | names = getivar(cls,CVARS); | for (n = 0; consp(names); ++n) { | if (car(names) == sym) { | *pval = getelement(getivar(cls,CVALS),n); | return (TRUE); | } | names = cdr(names); | } | } | | /* variable not found */ | return (FALSE); |} Note the lines above marked with '+'. > Why should it? Because otherwise, what's the point of having instance variables, or OOP, for that matter. As to your other questions, hopefully somebody else will answer, as I am very busy. ------------------------------------------------------------------------------- Niels Mayer -- hplabs!mayer -- mayer@hplabs.hp.com Human-Computer Interaction Department Hewlett-Packard Laboratories Palo Alto, CA. *