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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.121.163 with SMTP id ll3mr12030893pab.26.1406403423774; Sat, 26 Jul 2014 12:37:03 -0700 (PDT) X-Received: by 10.182.109.234 with SMTP id hv10mr181427obb.2.1406403423500; Sat, 26 Jul 2014 12:37:03 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!h18no8184952igc.0!news-out.google.com!eg1ni5igc.0!nntp.google.com!h18no4825162igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 26 Jul 2014 12:37:03 -0700 (PDT) In-Reply-To: <98ydnZoYn_c9Yk7O4p2dnAA@giganews.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.57.209.48; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 173.57.209.48 References: <98ydnZoYn_c9Yk7O4p2dnAA@giganews.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: If a routine should return two results, how should it be done? From: "Dan'l Miller" Injection-Date: Sat, 26 Jul 2014 19:37:03 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:21263 Date: 2014-07-26T12:37:03-07:00 List-Id: On Saturday, July 26, 2014 2:21:03 PM UTC-5, Peter Chapin wrote: > On 2014-07-26 14:57, Victor Porton wrote: > > I want to create a thick Ada binding for the following C function: > > http://librdf.org/raptor/api/raptor2-section-uri.html#raptor-uri-uri-st= ring-to-filename-fragment > > char * raptor_uri_uri_string_to_filename_fragment > > (const unsigned= char *uri_string, > > unsigned char = **fragment_p); > > Which variant is better for this specific case: 1 or 3? >=20 > If you're creating a thick binding you don't need to limit yourself to > the same collection of functions provided by the underlying library. > You're in a position to define the types abstractly and write > subprograms that expose the needed functionality without regard to the > specific underlying functions. >=20 > I would expect a thick binding to merely use the underlying library to > implement a higher level (cleaner, more abstract) interface. It's not > about providing a binding to each underlying function one-to-one. That's > a thin binding. Yes, Victor, to be clear: so far, you are writing a relatively thin bindin= g, judging from the postings here at c.l.a that you have made. As Dmitry &= I have encouraged (and now apparently Peter as well), your thick binding w= ould have a URI record or tagged record. You would go through the entire u= nderlying C library looking for OOish objects to represent as 1st-class cit= izens in your thick binding, not buried implicitly, scattered hither & yon = in the C way of thinking. You would decide how many URI syntaxes/domains t= hat you want to support: e.g., only URLs in WWW browsers?, not general URN= s of, say, ISBNs? If strictly URLs, then perhaps you would forego URI supe= rclass entirely, since URNs for far-afield topics would be uninteresting to= you. If strictly URLs, then which protocols, e.g., all of them {http, htt= ps, file, ftp, ...}? If only a subset, then perhaps the thick binding adds= much value for treating URLs for http & https as having many http/https-sp= ecific behavior beyond mere string processing. Likewise for files. Likewi= se for ftp or any other protocol. Perhaps protocol is the OO design to emp= hasize most and URIs or URLs or URNs are secondary or truly buried as mere = parameters here & there. In other words, take the C library and rethink it= as if it did not exist, as if you were writing it from scratch. What woul= d you like to see the main entities be and how would you like them to behav= e most sanely? Then, implement that OO API via the Raptor C library with a= little or a lot of glue code between your Ada desired-state API and the (c= lunky?) Raptor C API's vision or lack thereof. As Peter said: ... > That's what makes them better. :) Btw, URN examples far afield from WWW-browsers' URLs: http://en.wikipedia.o= rg/wiki/Uniform_Resource_Name#Examples