:: Re: [DNG] Making sense of C pointer…
Top Pagina
Delete this message
Reply to this message
Auteur: Didier Kryn
Datum:  
Aan: dng
Onderwerp: Re: [DNG] Making sense of C pointer syntax.
Le 29/03/2016 10:30, Edward Bartolo a écrit :
> Sometimes, a generic pointer is very useful. For instance, the Windows
> API documents functions that have untyped pointers. These allow great
> flexibility and behave like the variant type in other languages but
> with efficient memory consumption. Delphi Pascal has both the variant
> and untyped pointer types. This clearly shows there are advantages to
> having the possibility of using untyped pointers. The Windows API
> CreateProcess function is such an example.


     Using pointers to untyped arguments is loose programming. It is 
like removing the handrail of your balcony to unhide the view. It gives 
good looking code which is easier to write and read but deadly 
error-prone. This is definitely non-professional.


     In case it's really worth the pain, you can use polymorphic 
variables in C: a struct containing a discriminant and a union, the 
discriminant indicating which member of the union to use. The actual 
implementation of an object is probably not different of this, with the 
difference that the compiler and the run-time library perform the 
discrimination and checking for you, which is safer of course.


     Didier