This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Multiple Values in Kawa


Nigel Dolby wrote:
Given that Kawa is pretty effective for prototyping and that the Common Lisp handling of multiple values provides a significant increment of prototyping capability, it seems to me that it would be worth trying to make the Common Lisp functionality available in Kawa Scheme. This doesn't necessarily mean that it should be a default. The crucial consideration is that, if I modify an existing function to return multiple values when it previously returned a single one, all existing calls on the modified function should continue to work as before without any code changes (thus, let-binding to capture the first value is not a preferred solution).

Is it really any easier than changing:


(define (existing-foo)
  (calculate-value1))

to:

(define(foo-2)
  (list (calculate-value1) (calculate-value2))
(define (existing-foo)
  (car (foo-2)))

The difference between the two approaches is that you "overload"
based on the return context.  Is i convenient?  Sure.  Does it
make anything noticable easier?  I'm not convinced.  Is it worth
it?  Perhaps.

Without any knowledge of the implementation, it seems that it might be possible to add a form similar to "values", perhaps named "optional-values" or "ignorable-values", that would explicitly call for the Common Lisp functionality in the code of the function that is returning the multiple values, which is already necessarily undergoing change in the prototyping scenario. This would allow people who prefer to use strict-checking functionality to use "values", and those who prefer flexibility to use the new form. If this is feasible, it seems that it might satisfy all the requirements and do so without foreclosing sequence functionality in XQuery.

It's not trivial to do it without penalizing the normal single-value solution. It is possible, but it probably requires changing mechanism by which Scheme function calls are implemented in the Java VM. I do want to do that anyway to support continuations.

So support for this feature (or the Common Lisp mechanism) may be
considered as part of adding support to full continuatons - but
not until then.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]