|
|
> Ah.. So, we should fix the problem created by adding flexibility to
> the languages, so we can do more than pre-tested, pre-coded, very
> strict things, by getting rid of all the flexibility? Somehow that
> seems... kind of problematic. lol
Well, the C language does not specify that pointers to objects ("data
pointer", incl. void*) can be converted to function pointers nor vice versa.
The POSIX environment enforces this to allow library calls such as
dlsym() that does not distinguish between object pointers and function
pointers. But you cannot change the interface into dlsym_obj()
(returning a void*) and dlsym_func() because C does not have the concept
of generic function pointers and function pointers of different types
cannot be "converted" into each other.
I've used C (with a subset of C++ that was implemented in their
compiler) on a DSP that uses data pointers that have a different size
(and underlaying semantics) than function pointers:
http://roker.spamt.net/c++/datatypes_c55x.png
The same thing as in the MEDIUM or COMPACT memory model used in good-old
DOS ages. :-)
So don't blame (the inventors of) C, but blame the UNIX/POSIX guys who
"invented" the flat memory model and seduced legions of C programmers to
expect that "pointers are integers" and so on…
Lars R.
Post a reply to this message
|
|