This is the mail archive of the guile@sourceware.cygnus.com 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)



"C. Ray C." <crayc@206.31.63.15> writes:
> On Mon, Feb 28, 2000 at 03:52:26PM -0500, Jim Blandy wrote:
> > Going cheerfully but completely off-topic: sure.  But I don't consider
> > using Scheme's data structures as containers for arguments and return
> > values to be practical, because it's so inconvenient.  It's simply
> > nicer to write
> > 
> >     (define (fetch type source) ...)
> > 
> > than
> > 
> >     (define (fetch . args)
> >       (let ((type (car args))
> >             (source (cadr args)))
> >         ...))
> > 
> > I mean, really.  Whereas in ML, it's just
> > 
> >     fun fetch (type, source) = ...
> > 
> > The ( , ) syntax is *not* specifically for function arguments.  It's
> > the syntax for building tuples.
> > [...deleted]
> > Then I can say:
> > 
> >    let val (quotient, remainder) = divide (a, b)
> >    in ...
> > 
> > You get multiple return values in a completely natural, consistent,
> > and convenient form.
> 
> That sort of thing would be useful, but a new data type isn't
> necessary. Perhaps you could add something like a list binding macro,
> where you bind elements in a list to variables.

Right --- I didn't mean to imply that there was something magic about
the tuple type that made ML's arrangement better than Scheme's.  In
this context, tuples and lists are equivalent, I think.  The issue is
one of natural and clear syntax.

For example, if Scheme let you say things like

    (let (((a b c) (foo)))
      ...)

which would require FOO to return a three-element list, and bind those
elements to the new variables a, b, and c, why, I'd consider that
equivalent to the let I described above.

Then the only remaining issue would be that argument binding in calls
is still a special sort of matching, when it should be available at
all convenient places in the language.

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