From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Subject: Re: Publishing with Lzip Date: Wed, 13 Mar 2019 15:43:32 +0100 Message-ID: <87ef7a7s2z.fsf@gnu.org> References: <87mum2zixw.fsf@ambrevar.xyz> <874l88fcwo.fsf@gnu.org> <87wol4gqk0.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:33219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h456W-0001Io-JQ for guix-devel@gnu.org; Wed, 13 Mar 2019 10:43:37 -0400 In-Reply-To: <87wol4gqk0.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Tue, 12 Mar 2019 14:39:27 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Pierre Neidhardt Cc: guix-devel Hi! Pierre Neidhardt skribis: >> I=E2=80=99d also recommend to re-read the API doc in the headers or what= ever. >> IME these APIs are very tricky to use and one has to pay attention to >> every small detail. > > I read the manual too many times. The headers are not documented. The e= xamples > don't tell us more about the API. > > I might be too inexperienced in the area, so maybe you or someone else co= uld > have a look at the manual. > > Else we could contact the maintainer and ask directly :D Well, we=E2=80=99ll see! >> According to the C standard an enum is an =E2=80=98int=E2=80=99. So map= ping them is >> just a matter of producing/consuming ints. The values of the enum start >> from 0 and are incremented by 1 from then on, unless specific values are >> provided. > > My question was whether it's possible to have the mapping done "symbolica= lly." > In C, you would match error values again the symbols of the enum, not aga= inst > the number. So if we map the error numbers manually in Guile, it would b= reak > whenever the API updates the enum. > > Maybe I'm just being overly picky here :p Indeed. :-) The funny thing with the FFI is that it gives =E2=80=9Ca whole bunch of new flexibility=E2=80=9D to shoot yourself in the foot. So for enums, while you could do something fancy to extract the values from the headers (using nyacc=E2=80=99s ffi-helper, or by running the C compiler at macro-expansion time), what I would recommend is to just grab them once and for all. :-) In practice that works well: C library writers have an incentive to keep ABI compatibility, so they=E2=80=99ll rarely change enum values. This is especially true for a library like this one whose API is probably set in stone given that the scope of its functionality is well-defined. We did that for example in Guile-Gcrypt and Guile-Git and everything works fine. That also means that it=E2=80=99s a good idea to have unit tests that exerc= ise all the bindings. HTH! Ludo=E2=80=99.