This is the mail archive of the guile@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: multiple return values



Sure --- passing a continuation function is a nice way to return
multiple values.  Here's an example of a function that does so (in a
gross hack not yet ready for public consumption):

;;; (http:head/redirections url k)
;;; Use the HTTP "HEAD" method to determine the content type of a web
;;; page, following any redirections.  Apply K as follows:
;;;     (K URL TYPE BODY)
;;; where:
;;; URL is the actual URL of the document, after following redirections
;;; TYPE is the content type of the document, and
;;; BODY is the full body of the reply.

However, in Guile's Scheme/C interface, C functions can't do tail
calls.  If you use a cps-style primitive in a loop, the stack will
grow for each iteration.  Sure, you can have a Scheme wrapper around
the C function, but then the C function would just need to return a
list to the Scheme code anyway.

So if Sascha wants a primitive to return multiple values, I think a
list is the way to go for now.