Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!rice!news!gateley From: gateley@rice.edu (John Gateley) Newsgroups: comp.lang.scheme Subject: Re: Programming style Message-ID: Date: 23 Sep 90 03:07:15 GMT References: <9009220456.aa01422@mc.lcs.mit.edu> Sender: news@rice.edu (News) Organization: Rice University Lines: 49 In-Reply-To: shivers@A.GP.CS.CMU.EDU's message of 22 Sep 90 08:54:30 GMT In article <9009220456.aa01422@mc.lcs.mit.edu> shivers@A.GP.CS.CMU.EDU (Olin Shivers) writes: Technique n-1: This technique can cause problems - what if you need to fix a bug and reload the file; how do you make sure the counter is reset to the appropriate number? This problem is exacerbated (my big word for the week) by multiple files. Suppose you make one of these macros available as part of a general macro pagkage, and a programmer uses one of these macros for two different purposes. The counter will be interleaved between the two, which is not what he wants. Technique n: A minor point here: you claim that this allows loops to be implemented efficiently (because there is no explicit branch instruction I think). However, a compiler which recognizes loops (and all the ones I know about recognize them from more normal constructs) has the ability to do many optimizations on them. In addition, the branch instruction that you think you are saving is not really saved - it is still present in the branch of the interpreter loop which is running. Some short-sighted individuals will point out that these programming techniques, while certainly laudable for their increased clarity and efficiency, would fail on compiled code. Okay, call me short sighted, I don't care :^). Sadly, this is true. At least two of the above techniques will send most compilers into an infinite loop. But it is already known that most lisp compilers do not implement full lisp semantics -- dynamic scoping, for instance. This is no longer true - consider Common Lisp. All CL compilers do implement dynamic scoping (and it's not even hard). In fact, it is possible to write a Lisp compiler which can handle the two techniques given above. The self modifying code raises some questions about what exactly the semantics of macros are, but it is still doable. Catching recursive lists is easily done (similar to *print-circle* of CL) and then the compiler has a handle on the looping structure. John gateley@rice.edu -- Edweena went to Calumet and left from there to college the she took along her porcupine whose name was known as knowledge res Now their relationship was filled with pangs of loving hunger ide the porcupine would question all but all she knew was slumber nts