Returning errno as a second value

Felix Filozov ffilozov at gmail.com
Wed Aug 14 10:04:10 UTC 2013


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.

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


On Wed, Aug 14, 2013 at 12:15 AM, Luís Oliveira <luismbo at gmail.com> wrote:

> Felix Filozov <ffilozov at gmail.com> writes:
>
> > If I understood Duane Rettig's response correctly, when a thread binds
> > a special variable using a let, that binding is only visible for that
> > particular thread. Is this how other Lisps behave?
>
> All CLs I'm aware of behave like that, yes.
>
>
> > With that in mind, in order to make with-errno work, the foreign
> > function call expression would have to be identified and bound with a
> > let.
>
> Why is that? I was thinking that the interface could work as follows:
>
>   1. WITH-ERRNO establishes a dynamic binding (cffi-sys:*errno* for
>      instance)
>   2. FOREIGN-FUNCALL does something like
>        (when (boundp '*errno*) (setf *errno* <errno>))
>   3. GET-ERRNO simply returns the value of *errno*
>
>
> > You mentioned that a foreign function call could return errno as the
> > first value, how about returning it as the last?
>
> That would be much simpler wouldn't it? I wonder if we can avoid
> consing, at least for the single return value case... If all else fails,
> simply documenting that grabbing errno entails discarding all but the
> first return value might be a solution.
>
>
> > Another alternative is to optimize the way synchronization is done, so
> > that we could improve the thread-local code I wrote before.
>
> I don't have any good ideas on that front.
>
> Luís
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20130814/b8266e77/attachment.html>


More information about the cffi-devel mailing list