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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7b65fc33a05f24b6 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!news.k-dsl.de!news.motzarella.org!motzarella.org!news.motzarella.org!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: A curiosity... Date: Fri, 05 Dec 2008 08:42:56 -0800 Organization: None to speak of Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.motzarella.org U2FsdGVkX19QMyrw8H3BDqBq/CzOXO4UuU4e9hfCWXt8XLpQG5o5hZR/EFkeImseXF8Z9lJQxrMpU0hYGx+HVrm9k71FscslLp1lGLEL+LobxW+vA0WOKRKsRxsLqZzWP1oEIQexfy0= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Fri, 5 Dec 2008 16:42:56 +0000 (UTC) X-Auth-Sender: U2FsdGVkX18fcE3djfC7KbZZ4KMF/yK9 Cancel-Lock: sha1:ZdBj/67oUB/1dnV84rfWKeQlY+M= sha1:5i8Kc9SU+0M8zfaLFmHIJ2HY2K0= User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (gnu/linux) Xref: g2news2.google.com comp.lang.ada:3865 Date: 2008-12-05T08:42:56-08:00 List-Id: Hyman Rosen 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 Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"