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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b582310cfc030f2c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-14 13:48:42 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.mathworks.com!wn13feed!wn11feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!rwcrnsc52.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3F8C6124.5040208@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Mixed languages and frustration. References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc52.ops.asp.att.net 1066164521 24.34.139.183 (Tue, 14 Oct 2003 20:48:41 GMT) NNTP-Posting-Date: Tue, 14 Oct 2003 20:48:41 GMT Organization: Comcast Online Date: Tue, 14 Oct 2003 20:48:41 GMT Xref: archiver1.google.com comp.lang.ada:859 Date: 2003-10-14T20:48:41+00:00 List-Id: Freejack wrote: > Alright, so I'm sitting here trying to juggle between C pointers and Ada > access types/allocators, with moderate success. And I start wondering to > myself "How many people on comp.lang.ada nearly blow a fuse when doing > the same thing?" > > So I'm curious, are juggling the two types(pun intended) as chaffing for > you as it is for me? Maybe I just dont know enough about the Interfaces > libs yet. No, eventually you will learn to do it the way we do. Create a package that contains all the C cruft and hides it from anyone using the package. The basic rule is that if you are using C pointers, the visible Ada abstraction should be a private--or limited private type. That way all the headaches are confined to one section of code. Oh, and don't forget that you can have several Ada subprograms (usually with the same name) that correspond to a single C function. Also often you want to have the Ada "wrapper" subprogram translate -1, etc. return values as exceptions. This is expecially true with those C functions that either use the storage your pass them, or allocate storage if the pointer passed is null. Treating that on the Ada side as a procedure and a function that happen to have the same name is often the right binding. (And even then, the wrapper function may copy the return value when the C function does the allocation into an Ada structure, free the pointer than return the structure. Sounds a lot more complex than it is.) -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig