[comp.lang.scheme] How to redefine a procedure

gjc@mitech.COM (04/04/91)

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.

jinx@zurich.ai.mit.edu (Guillermo J. Rozas) (04/05/91)

    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).

This issue is independent of the rest.  Scheme does not currently have
&KEY arguments, and if they were added to LAMBDA expressions, they
would automatically work for return values as long as the primitive
for collecting multiple values was 

(call-with-values <value-generating-thunk>
  <consumer-procedure>)

krulwich@ils.nwu.edu (Bruce Krulwich) (04/12/91)

In article <9104041549.AA16630@schizo>, gjc@mitech writes:
>What did prove useful to extending the calling conventions of
>a procedure was &KEY arguments.
...
>Did anyone ever propose the use of &KEY return values?
...
>p.s. I really think I *have* heard of somebody suggestion &KEY
>in multiple return values. I just cannot remember who or when.

It seems to me that this idea comes naturally if returning multiple values is
thought of as simply calling a continuation with more than one argument.  If
you're working in CL or another LISP with keyword arguments, why shouldn't
continuations have them just like all other procedures?

As a side note, in this view of multiple-value returns, the functions such as
RECEIVE-VALUES in T (and I suppose MULTIPLE-VALUE-CALL in CommonLISP) are
simply giving an explicit continuation to pass to another procedure.

Bruce Krulwich
krulwich@ils.nwu.edu

 

mkatz@garlic.stanford.EDU (Morris Katz) (04/15/91)

   Date: 12 Apr 91 15:25:22 GMT
   From: Bruce Krulwich <krulwich@ils.nwu.edu>
   Organization: Institute for the Learning Sciences, Northwestern University, Evanston, IL 60201

   In article <9104041549.AA16630@schizo>, gjc@mitech writes:
   >What did prove useful to extending the calling conventions of
   >a procedure was &KEY arguments.
   ...
   >Did anyone ever propose the use of &KEY return values?
   ...
   >p.s. I really think I *have* heard of somebody suggestion &KEY
   >in multiple return values. I just cannot remember who or when.

This was discussed briefly at the Scheme meeting in Snowbird.  It was mentioned
in the context of a larger discussion of multiple values and not as a proposal
since Scheme does not have keyword arguments.
--------------------
Morry Katz
katz@cs.stanford.edu
--------------------