Returning errno as a second value

Luís Oliveira luismbo at gmail.com
Wed Aug 14 13:04:39 UTC 2013


Felix Filozov <ffilozov at gmail.com> writes:

> Maybe we can even do this using lexical binding, since GET-ERRNO could
> be a macro that expands to a lexical variable introduced by
> WITH-ERRNO.

The issue there is that foreign-funcall will be setting errno.


> Could you elaborate where there's a consing issue, if errno is
> returned as the last, or first, value?

So, the pseudo-code for the implementation in foreign-funcall would be
something like:

  (multiple-value-bind (return-value errno)
      (%foreign-funcal ...)
    (let ((translated-return-values (multiple-value-list (translate-from-foreign ...))))
      (values-list (cons errno translated-return-values))
      ;; or (values-list (nconc translated-return-values (list errno)))
      ))

Right now I'm inclined to discard all but the first translated return
value. (This is your initial solution, isn't it?)

Luís




More information about the cffi-devel mailing list