Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!dont-send-mail-to-path-lines From: gjc@mitech.COM Newsgroups: comp.lang.scheme Subject: How to redefine a procedure (extend it) and have nobody notice Message-ID: <9104041549.AA16630@schizo> Date: 4 Apr 91 12:43:07 GMT Sender: daemon@athena.mit.edu (Mr Background) Reply-To: gjc@mitech.com Organization: The Internet Lines: 62 Being able to extending a procedure in an upward compatible way so that old code doesn't notice. Ah, that age old desire. (It ain't spring in New England quite yet). It is true that multiple values and &optional and &rest arguments were useful in some cases, and were used quite often in the development of the Lispmachine software, for the purpose of extending the functionality of a function without having to "relink" old code. (or edit/recompile if you will). However, what you could do along those lines at some point became more and more difficult, with the end result of stranger and stranger argument/return-value calling sequences. [Note: It is certainly easier to beleive me here if you were witness, victim and/or criminal to these 10 years of lisp/operating-system evolution.] In the case of extending QUOTIENT to returning two values, certainly old code that had no idea of VALUES or VALUES-LIST at all would have a good chance of continuing to work, but you can bet that someplace deep inside a package like Macsyma there might lurk a procedure that actually counted how many values something returned. (In fact, in Macsyma I know this to *not* be the case. But you get the idea). Sorry for diverting to an example. What did prove useful to extending the calling conventions of a procedure was &KEY arguments. (Except of course that some procedures used &REST and wanted to process a list of arguments, augment them, and then pass them on to some other &KEY procedure. It was tricky to write such code in an extensible manner). Did anyone ever propose the use of &KEY return values? I'm suprised that I never heard of any such proposal. (In the Lisp world I know of). On the other hand, in the REAL WORLD, of IBM and DEC mainframe/database programmers for example, such things as abstract ideas of procedure calls with NAMED arguments are pretty standard stuff, since code must be written in such a way that it continues to work on database structures that are continuously evolving. And in that real world, minor efficiency considerations such as stack format and register saving/usage that seem to give some of the Scheme people on this list a reason for living, just don't matter very much. (Things have to get written to DISK a lot, is one way to start thinking about the real world). OK. I am abusing the definition of what constitues a "procedure" call and what consitutes an "argument" somewhat. -gjc p.s. I really think I *have* heard of somebody suggestion &KEY in multiple return values. I just cannot remember who or when.