comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst-u@mib.org>
Subject: Re: A curiosity...
Date: Fri, 05 Dec 2008 08:42:56 -0800
Date: 2008-12-05T08:42:56-08:00	[thread overview]
Message-ID: <lnzljashdb.fsf@nuthaus.mib.org> (raw)
In-Reply-To: pfZZk.25421$Jl5.18494@newsfe19.iad

Hyman Rosen <hyrosen@mail.com> writes:
> Randy Brukardt wrote:
>> Every C-language interface that I've every used is
>> full of hacks to get around strong typing.
>> ...
>> Perhaps C programmers are so used to cruft that they
>> fail to abstract it away properly, but that reflects
>> more on the programmers (and the culture that they
>> work it) than the language.
>
> I don't think that's particularly fair, or right.
> The main issue that the sample exposes is that when
> you have a library which needs to accept user objects
> and pass them back into user code, it's going to be
> difficult to define the interface properly without a
> lot of mechanism.
>
> It really is the case that all pthread_create wants
> to do with that pointer is hand it back once it starts
> the thread. I expect that in modern C++, this would
> get wrapped in template code to make sure that the
> type of the pointer passed matches the argument type
> of the thread function, and I guess Ada would use
> generics similarly, but in a C interface, you just do
> the cast and leave it at that.

Except that there's no guarantee in C that converting an int to void*
and back again will yield the original int value.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



  reply	other threads:[~2008-12-05 16:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-04 20:47 A curiosity mockturtle
2008-12-04 21:17 ` Adam Beneschan
2008-12-04 21:48   ` Hyman Rosen
2008-12-04 22:04     ` Ludovic Brenta
2008-12-04 22:10       ` Ludovic Brenta
2008-12-04 22:24         ` Hyman Rosen
2008-12-05  8:02         ` Samuel Tardieu
2008-12-05 11:51           ` Peter C. Chapin
2008-12-05 13:09           ` Martin Krischik
2008-12-05 15:15             ` Hyman Rosen
2008-12-06 13:26             ` Peter C. Chapin
2008-12-05 16:37           ` Keith Thompson
2008-12-04 22:19       ` Hyman Rosen
2008-12-05  9:03       ` Georg Bauhaus
2008-12-04 22:30 ` Randy Brukardt
2008-12-04 22:57   ` Hyman Rosen
2008-12-05 16:42     ` Keith Thompson [this message]
2008-12-05 16:57       ` Hyman Rosen
2008-12-05 20:20         ` Keith Thompson
2008-12-05 20:59           ` Adam Beneschan
2008-12-06 22:53             ` Hyman Rosen
2008-12-06 23:15               ` Gary Scott
2008-12-08 15:39                 ` Hyman Rosen
replies disabled

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