[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 18/25] write documentation for (system foreign declarative)
From: |
Dmitry Bogatov |
Subject: |
Re: [PATCH 18/25] write documentation for (system foreign declarative) |
Date: |
Mon, 18 Jul 2016 23:11:04 +0300 |
[2016-07-18 21:41] Amirouche Boubekki <address@hidden>
>
> On 2016-07-18 17:17, address@hidden wrote:
> > From: Dmitry Bogatov <address@hidden>
> >
> > Document '<foreign-type>' record type and 'define-foreign-type'
> > procedure.
>
> Can you compare this 'foreign-type' library with scheme-bytestructures
> [0]. How
> can both libraries help each other? Work hand in hand?
Seems that 'scheme-bytestructures' can be used to implement something like
`define-foreign-struct', but since it is not currently part of Guile, I, sure,
can't depend on it.
Also, 'parse-c-struct' provides similiar functionality.
> Tell me if I'm wrong but it looks like you have to define validate,
> encode and decode proc for every single structure with no
> helpers.
Not true. Sure, if your conversion is somewhat unusual, you have to
invoke `(define-foreign-type)', but if it conventional, you can use
- define-foreign-bitmask
(in future)
- define-foreign-struct (did not extracted from guile-bash)
- define-foreign-enumeration
- define-foreign-opaque
(last two are really trivial, just I did not needed them for xattr library)
> It seems to me that it's some kind of framework for doing validation
> of static typed procedures which also handles automatic conversion
> between C land and scheme land. Honestly this is not the kind of
> library I would use, I seldom do input validation when the client of
> my program is a developer. Maybe I'm wrong but IMO dynamic languages
> help that.
Our opinions on validation differs. I think, that foreign function
binding, created by (system foreign declarative) should be as good, as
if written in C. By this I mean, I want to get error message out of
function itself, not from some guts of (system foreign declarative).
> Also based on my small experience of ffi, there is not much
> conversion to do between scheme and C and what's best is to avoid
> any copy which is what does scheme-bytestructures.
(system foreign declarative) provide a way to work with memory with no copy:
(with-pointer ((memory *--> 1024))
(foreign-call memory)
(work-with-bytevector memory))
But take a look at (ice9 xattr) (patches 21-25).
Conversion from Scheme string to `const char *' have O(n) price, but I
prefered natural interface to perfomance. But again, (system foreign
declarative) does not force such choice.
It seems to me, that I responded to every point, but feel free to
refine your question.
--
Accept: text/plain, text/x-diff
Accept-Language: eo,en,ru
X-Web-Site: sinsekvu.github.io
- [PATCH 09/25] system/foreign/declarative: rename `predicate' to `validate', (continued)
- [PATCH 09/25] system/foreign/declarative: rename `predicate' to `validate', KAction, 2016/07/18
- [PATCH 11/25] system/foreign/declarative: new macro, KAction, 2016/07/18
- [PATCH 13/25] system/foreign/declarative.scm: export string foreign type, KAction, 2016/07/18
- [PATCH 12/25] Improve deriving c symbol name from scheme one, KAction, 2016/07/18
- [PATCH 14/25] foreign/declarative: mirror more primitive types, KAction, 2016/07/18
- [PATCH 15/25] New macro: with-pointer, KAction, 2016/07/18
- [PATCH 16/25] Configure emacs file-local indention, KAction, 2016/07/18
- [PATCH 17/25] system/foreign/declarative: unexport internal macro, KAction, 2016/07/18
- [PATCH 18/25] write documentation for (system foreign declarative), KAction, 2016/07/18
[PATCH 20/25] Document with-pointer macro, KAction, 2016/07/18
[PATCH 19/25] Document define-foreign-bitmask macro, KAction, 2016/07/18
[PATCH 21/25] new module: (ice-9 xattr), KAction, 2016/07/18
[PATCH 22/25] ice-9/xattr: implement `xattr-get' function, KAction, 2016/07/18
[PATCH 24/25] Refactor defining foreign libattr function, KAction, 2016/07/18
[PATCH 25/25] ice9/attr: implement xattr-list procedure, KAction, 2016/07/18
[PATCH 23/25] Do not throw exception on missing xattr, KAction, 2016/07/18