On Sun, 16 Jan 2000, Erik Thiele wrote:

> > > is everything in ggi a void* ?
> > 
> > This is a valid point. We do that void * stuff on pupose to make sure users
> > don't try to dereference stuff they shouldn't (bypassing the encapsulation
> > rule and the access layers). However in cases like yours, it's in the way ... 
> > Ideas ?
> i never contributed to ggi, and do not really know about it's structure.
> but if you ask me this question, i just think it is bad style.
> in my eyes it is a very bad idea to do something in a void* just to
> ensure nobody dereferences it.
> i think it is enough to say "you mustn't dereference it, it is internal"
> you not need to force users to this via void*
> i think better style to write things as they really are.
> not casting void* to something else internally, but just always using
> the correct type.
> - improves debugging (you really see the structure, not a nonsensical void
>                       pointer)
> - the compiler won't compile stupid code anymore (type safety)
> - eliminates casts from void* to something else in the internal
>   ggi library.
> for me the idea with the void* is very bad design.

void* is officially in computer science a valid idea :)
It has to do with the publically accessed side having full informational
access to something which may vary behind the scenes.

Stylistically, from what I remember in CS, a void* is the ultimate example
of the minimum front-end required to talk to an object where the
behind-the-scenes code can vary.  It's the old implementation/interface
barrier.  It's "Good Practice" officially AFAIK.

A void* system solves these problems:
- Object-based system where the real structure is a superset of some basic
        type, such as struct base {int type; };
- User data can be set to a void* container and not be touched by the
        driver-side -> just remembered.  (callbacks)
- Driver data can be stored here, and it can be driver-specific stuff such
        as the X contexts and Windows thread-ID's for example.

Plus prolly other things I can't think of right now.

G'day, eh? :)
        - Teunis

Reply via email to