This is the mail archive of the mailing list for the Guile project.

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

Re: values (Re: R5RS)

On Sun, Feb 27, 2000 at 11:27:47PM -0500, Jim Blandy wrote:
> But since you've gone to all the trouble of designing rules for
> handling multiple values on the way in, why shouldn't you amend your
> language allow multiple return values too, and use the same set of
> rules for handling them on the way out?  You've already figured out
> how to pack a tuple of arguments into registers; why not use those
> same rules for passing a tuple of return values back?  Taking the time
> to empower calls, but then crippling returns, seems stupid.
> Anyway, ML handles this whole issue much more gracefully than Scheme.
> Calls and returns are symmetrical: they both carry exactly one value.
> But then they have very clear, terse ways to make that one value a
> tuple.  Mission accomplished.  And no call/cc involved.
> What I'd like is a way to call a function with only as many arguments
> as it expects.  That is, I've got five arguments I could pass, but if
> the function only takes three, that's cool, just pass the first three.
> Then, I could apply this to `values', and return only as many values
> as the caller expects.  So I could have a division function which
> returns the remainder too, but only if the caller was prepared for two
> return values.

Well... if you only called functions with one argument in Scheme,
you'd end up using either lists or vectors a lot. As long as you don't
use null?/length on lists, or vector-length on vectors in the function,
you would just ignore the extra arguments. Or, of course, you can test
for extra arguments. The same is true in reverse.

Actually, I just realized we already have a special syntax for that...
(define (func . args))

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