From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d1533431e7e9d2eb X-Google-Attributes: gid103376,public From: tmoran@bix.com Subject: Re: Nontrivial examples of C interface with Ada Date: 2000/05/25 Message-ID: #1/1 X-Deja-AN: 627033890 References: <392CC733.13BDDC84@quadruscorp.com> X-Complaints-To: abuse@pacbell.net X-Trace: news.pacbell.net 959233108 206.170.24.48 (Wed, 24 May 2000 22:38:28 PDT) Organization: SBC Internet Services NNTP-Posting-Date: Wed, 24 May 2000 22:38:28 PDT Newsgroups: comp.lang.ada Date: 2000-05-25T00:00:00+00:00 List-Id: > > "semi-thick" binding is one that abstracts away typical stupid C > > artifacts like pointer interfaces, return error codes, and > > null-termiated strings. That way the interface "feels" like Ada. But it > > doesn't abstract things so much that the C docs for the routine can't be > > used for the Ada bindings. > ... > However, you at least want to attempt to make it close to the original routine, Even though your code now looks Ada-ish and has strong typing, exceptions, etc. you will still be operating at a very low, C-ish, level of abstraction, Will you, for instance, use the OS'es semaphore function calls, or use Ada protected records? Callbacks via procedure access values, or by overiding tagged record primitives? Suppose you want to open a socket connection, send some html text, and close it. Do you really want the ugly details of socket handling, or do you want a procedure Open, procedure Put, and procedure Close? My preference is to start from the point of view of someone about to design a spec for some abstraction (socket, Windows clipboard or dialog box, etc). "How would I do this in Ada?". Then the body tries to implement the abstraction using C calls. Admittedly, sometimes the simple, clean, abstraction needs some warts added to allow some of the strange functions, or to fit the restrictions of, the underlying C, but usually you can make something reasonably clean. You can't just do a translation of the C docs, but instead you have something that makes sense and can be explained, usually, more simply.