comp.lang.ada
 help / color / mirror / Atom feed
From: Lutz Donnerhacke <lutz@iks-jena.de>
Subject: Re: Interfacing to C: API with macros
Date: Tue, 12 Jun 2007 20:25:17 +0000 (UTC)
Date: 2007-06-12T20:25:17+00:00	[thread overview]
Message-ID: <slrnf6u09d.u32.lutz@belenus.iks-jena.de> (raw)
In-Reply-To: 1181679449.352274.217590@g37g2000prf.googlegroups.com

* Maciej Sobczak wrote:
> Yet Another Problem (YAP): consider a C function that is defined
> together with some helper macros. Motivating example: select(2) system
> call, with its FD_XXX helper macros.

Have a look at the semantics of those macros, you will notice, that they are
a application level language in C hiding the expressivness holes of the
language.

Now you have a higher level language and you are expected to use it!

> There is no way to pragma Import(C, FD_SET) and the binary layout of
> fd_set data structure is not specified, so we cannot fake it with Ada.

We can! We know that fdset_t is a bitarray on all known systems. Therefore
  type fdset is Array (0..1023) of Boolean;
  pragma Pack(fdset);
and you are done.

> Looks like in order to write any nontrivial system software the poor
> Ada programmer has to start with an awful lots of wrappers - where is
> maintainability and productivity when you need them? ;-)

If you try to meet your counterpart at the most evil place, your programm
will look as ugly as the counterpart. Use the abstraction of your language!
Programm what they mean, not what they code.



  reply	other threads:[~2007-06-12 20:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-12 20:17 Interfacing to C: API with macros Maciej Sobczak
2007-06-12 20:25 ` Lutz Donnerhacke [this message]
2007-06-13  0:18 ` tmoran
2007-06-13 14:06 ` Steve
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox