Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!XEROX.COM!Pavel.pa From: Pavel.pa@XEROX.COM Newsgroups: comp.lang.scheme Subject: Re: semantics of DEFINE Message-ID: <890503-103409-9762@Xerox> Date: 3 May 89 17:33:55 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 37 Too many people are referring to DEFINE as a form that ``side-effects the top-level environment'' for me to keep out of the fray. In the current (unreleased) draft of the Scheme specification, R^(3.95)RS, the following definitions appear (my wording): -- A program is a mixed sequence of definitions and expressions. -- The meaning of a program P is the same that that of the following expression: ((lambda (I*) P') ...) where I* is the set of variables defined in P (i.e., appearing as the CADR of a DEFINE form), P' is the sequence of expressions obtained by replacing each definition in P with the corresponding assignment, and is an expression producing some useless value. More informally, to execute a program, you wrap it in a big LET binding all of the defined variables to useless values, change the DEFINEs to SET!s, and evaluate that expression. Note, please: no mutation of any environment takes place. I believe that too many people base their understanding of the semantics of Scheme on a read-eval-print loop model or on the low-level details of particular (or perhaps all) implementations. It seems to me irrelevant that I might use side-effects to resolve the separate compilation (or just separate loading) of files of code with the semantics given above. The semantics of DEFINE, and therefore the most accurate way to conceptualize its meaning, has no mention of mutation. Of course, this little diatribe has no direct bearing on the meaning of internal DEFINEs. Personally, I'd rather they had the same meaning (as given above) as top-level ones. The meaning in terms of LETREC has always struck me as gratuitously incompatible, and frequently inconvenient as well. If you're going to use the same name, you should give it the same semantics... Pavel