Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   Web Development Archives FAQs Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Web Development Archives Sponsor:
  #1  
Old July 3rd, 2008, 08:20 AM
Ludovic Brenta
Guest
Dev Archives Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Interfacing to C and types visible to Ada

Maciej Sobczak wrote:
Imagine a C API that uses the int type to express something that does
not have any dedicated domain. In other words, it is not "number of
apples", not "height in meters", not "hotel room number", etc., it is
just plain "integer", which meaning can depend on how the given
library is actually used.

How about making the Ada binding generic, e.g.:

generic
type Integer_Type is range <>;
package Ada_Binding is
function Foo return Integer_Type;
end Ada_Binding;

with Interfaces.C;
package body Ada_Binding is
function Foo return Integer_Type is
function Internal return Interfaces.C.int;
pragma Import (C, Internal, "foo");
begin
return Integer_Type (Internal);
end Foo;
end Ada_Binding;

This way, the user of the library specifies the particular meaning of
the "integers" in each case. This design makes it possible to create
several instances of Ada_Binding with different meanings and then
benefit from Ada's strong typing.

--
Ludovic Brenta.

Reply With Quote
Reply

Viewing: Web Development Archives FAQs Programming > Interfacing to C and types visible to Ada


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway