Re: [OT] Re: [gtkmm] Re: pthreads with gtk/gtkmm
- From: Leslie Polzer <sky nachtwind net>
- To: Paul Davis <paul linuxaudiosystems com>
- Cc: gtkmm-list gnome org
- Subject: Re: [OT] Re: [gtkmm] Re: pthreads with gtk/gtkmm
- Date: Wed, 19 Feb 2003 15:14:22 +0100
On Wed, 19 Feb 2003 08:35:35 -0500
Paul Davis <paul linuxaudiosystems com> wrote:
> i agree with you about that, but it remains a problem and its not
> aided in any way by using static_cast<>. also "the interfaces are not
> clearly defined" applies to any situation where void * must be used
> because you are forced to abandon type safety. its not necessarily a
> reflection of a design or development process error as you imply:
> there are situations where this is necessary
Yes, the pthread authors for example don't know what the user's thread
function wants to accept.
> - i just feel that using
> reinterpret_cast<> serves as a reminder that neither we nor the
> compiler have any clue whatsoever what the void * actually is.
But we do - we know the Arg* gets in, and we get the Arg* out.
The code example we are discussing here is bad practice
anyway, the parameters can and should be given as int, char**;
there's no reason to use void* - but when we use interfaces
that have accept a void* for maximum flexibility the cast
should be static because we exactly know what we are storing
in memory and on which platform we do.
I may agree with your opinion if we read/wrote this data as a void*
from/to a file which may be transferred between different platforms.
> >[1] http://www.cs.rpi.edu/~wiseb/xrds/ovp3-1.html
>
> i suppose that one can argue, as this paper implicitly is doing, that
> the cast between void* and Anything* is built into the language. thus
> static_cast<> is right because we are performing a completely ordinary
> cast between two pointer types that are defined as convertable by the
> language: its a "standard conversion".
Same arguments as above apply here.
> however, that paper, like stroustroup, focuses on static_cast<> to do
> class navigation between parents and children,
I know, but look at the reinterpret_cast<> section - the author (and
I guess Stroustrup does, too) says one shouldn't use it until one is
desperately forced to do, so I'd say: it is a smaller problem and less
disturbing to use static_cast<> than reinterpret_cast<>.
Leslie
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]