On Sat, Jan 15, 2000 at 04:40:07AM +0100, Andreas Beck wrote:
> > i didn't do the correct code:
> >    if (ggiResourceMustAcquire(dbs[writeframe]->resource))
> >       if (ggiResourceAcquire(dbs[writeframe]->resource,GGI_ACTYPE_WRITE)!=0)
> > instead i did:
> >    if (ggiResourceMustAcquire(dbs[writeframe]))
> >       if (ggiResourceAcquire(dbs[writeframe],GGI_ACTYPE_WRITE)!=0)
> 
> > but i do not like that this compiles WITHOUT warnings about
> > type mismatchs !
> > 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.


and there is another point:
if you still want your hiding, you can do the following:

#ifdef __AM_INTERNAL_GGI_CODE #or WANT_REALITY_GGI_FOR_DEBUGGING
typedef struct {
  uint16 resource_id;
  uint8 is_locked;
  uint32 memory_address;
  uint16 page_number;
} ggi_resource_t;
#else
typedef struct {
  uint16 INTERNAL_DONT_USE_ME1;
  uint8 INTERNAL_DONT_USE_ME2;
  uint32 INTERNAL_DONT_USE_ME3;
  uint16 INTERNAL_DONT_USE_ME4;
} ggi_resource_t;
#endif

this way you would unite all the benefits of my idea and yours, i think.
because if a programmer really does  myres->INTERNAL_DONT_USE_ME2=34;
then he should be shot onto the moon anyway.

but that's just my 5 cents ;)

cu
erik


-- 
Name:  Erik Thiele                                       \\\\
Email: [EMAIL PROTECTED]                                o `QQ'_
IRC:   erikyyy                                            /   __8
WWW:   http://www.erikyyy.de/                             '  `

Reply via email to