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=0.7 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3cc61b675eac7c7a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.189.72 with SMTP id gg8mr7888159pbc.4.1327830392666; Sun, 29 Jan 2012 01:46:32 -0800 (PST) Path: lh20ni236909pbb.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: mockturtle Newsgroups: comp.lang.ada Subject: Re: Ada as glue ? logical approach ? Date: Sun, 29 Jan 2012 01:46:32 -0800 (PST) Organization: http://groups.google.com Message-ID: <33454168.606.1327830392053.JavaMail.geo-discussion-forums@vbuf18> References: <9e698480-636a-419f-9b50-400b322de8d4@dp8g2000vbb.googlegroups.com> Reply-To: comp.lang.ada@googlegroups.com NNTP-Posting-Host: 93.37.91.211 Mime-Version: 1.0 X-Trace: posting.google.com 1327830392 32187 127.0.0.1 (29 Jan 2012 09:46:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 29 Jan 2012 09:46:32 +0000 (UTC) In-Reply-To: <9e698480-636a-419f-9b50-400b322de8d4@dp8g2000vbb.googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=93.37.91.211; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 User-Agent: G2/1.0 X-Google-Web-Client: true Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-01-29T01:46:32-08:00 List-Id: On Sunday, January 29, 2012 5:53:21 AM UTC+1, Patrick wrote: > Hi Everyone >=20 > I have been studying ada for sometime now but I have no experience > coding with it. :-) I +1 what Simon told you: start coding. In my (humble) opinion, computer l= anguages and human languages share at least one characteristic: if you real= ly want to learn them, you must use them. Studying the grammar is useful a= nd it gives you an idea of the language, but if you want to master it you n= eed to use it. >=20 > It doesn't look like there are all the library bindings i want but I > am wondering if this really matters. >=20 > Someone could write a full binding for a library but could someone > also not just use the import pragma to "grab onto" the existing C > library APIs? >=20 Let me see if I understand your question. Let us consider, for example, th= e GNAT.Sockets library that refers to the socket C API and consider the pro= cedure to connect a socket. You are asking if you can do something like =20 pragma Import(C, BSD_Connect, "connect"); and then calling BSD_Connect directly instead of writing a procedure GNAT.S= ockets.Connect_Socket that in turn calls the connect() (imported with a pra= gma similar to the above one). If this is your question, the answer is that, yes, you can, but the resulti= ng code would not be very convenient to use. For example, depending on the= parameters of the C function, you need to convert from Ada parameter to C = parameter (e.g., Ada String to C char*) and this would be quite unconvenien= t to do every time you need to call the function. For me, I prefer to writ= e a tiny procedure that takes normal Ada parameters and hides the conversio= ns problem. =20 Note also that sometimes conversion could be a little tricky, so you do not= want to spread your code with tricky conversion stuff that could introduce= bugs; it is better to have the tricky part only in one place, write it and= debug it just once and forget about it. The only reason that I see for "grabbing" the "naked" C API is when you are= in a rush (e.g., you need the final version tomorrow) and you need to call= the C API in just few places. Of course, your mileage can vary. > This would be a bit like ctypes in Python correct ? Are other list > members writing their own 'as needed' partial bindings?=20 Yes, me too. As Simon told you, many bindings are just partial, no need to= interface with the whole C library. =20 > Is this a logical approach? -Patrick Riccardo