[Scheme-reports] values Razvan Rotaru (27 May 2011 07:23 UTC)
Re: [Scheme-reports] values John Cowan (27 May 2011 14:56 UTC)
Re: [Scheme-reports] values Razvan Rotaru (30 May 2011 08:04 UTC)

Re: [Scheme-reports] values John Cowan 27 May 2011 14:56 UTC

Razvan Rotaru scripsit:

> The truth is most of the time I'm interested in one value, not all
> of them. In my oppinion Lisp is right when assuming that one of the
> values returned as result is more important than others, and does not
> raise an error when I use such a function in a context where only one
> result is expected.

Use this trivial wrapper:

(define-syntax strip-values
  (syntax-rules ()
    ((strip-values exp)
     (call-with-values
       (lambda () exp)
       (lambda x (if (null? x) 'bogus (car x)))))))

> Additionally, in the way scheme treats multiple values, there is
> little difference between returning a list with the values, and
> returning the values as such (using the (values ...) form). I could
> very well use the list, and would not need to have the (values ...)
> form built into the language.

You could.  However, there may be a difference in performance.

--
An observable characteristic is not necessarily         John Cowan
a functional requirement.  --John Hudson                cowan@ccil.org

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports