malloc impossible? (was: inkey$, noecho, and other impossibles)
Chris Torek
chris at mimsy.UUCP
Fri Jan 13 22:22:53 AEST 1989
[same old perverse machine with integer and fp spaces]
In article <14658 at oberon.USC.EDU> english at panarea.usc.edu (Joe English) writes:
>Then how would you do this:
>
> struct impossible {
> int i;
> float f;
> double *dp;
> } imp;
>
>Even if the compiler were to allocate the three components of imp in
>the approprate address spaces, what is &imp? Does it point to imp.i,
>imp.f, or imp.dp? Or a vector of pointers (in the pointer address
>space, of course) which point to imp's components?
It would have to point to a vector of pointers; the actual contents
of the structure would really be
int *i;
float *f;
double *dp;
(it is only necessary to add a reference level to simple objects).
Grotesque? You bet!
>... "C-minus-malloc" wouldn't be much good unless it also provided a
>"new" operator -- I don't know about you, but *I* don't want to have to
>write my own malloc() routine along with every struct!
I agree. But I think that a standards committee might shy away
from adding malloc to a C-like language that did not already have
malloc (in fact, they would almost certainly add a `new' instead).
Standards committtees tend to be overly conservative. (Although they
can be radical sometimes, as witness `noalias'.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.lang.c
mailing list