malloc impossible?
Tainter
tainter at ihlpb.ATT.COM
Sun Jan 15 07:44:05 AEST 1989
In article <9351 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>Assuming that integers could not also live in floating-point space,
>C would not be implementable on such a hypothetical architecture.
Sure it can. Just not efficiently.
>Consider
> union {
> double d;
> int i;
> } u;
> u.d = 123.0;
> printf("%d\n", u.i);
>This is required to work, although the specific value printed of course
>depends on details of numeric representation on the specific system.
>All data object types in C must be able to live in the same kind of space.
>Whatever kind of space that is, is what one would parcel out via malloc().
>Therefore malloc() is implementable if C is (at the very least, along the
>lines I indicated in my previous example implementation).
This isn't even required to print anything useful.
To support this stuff you just give everything an indirection.
I haven't thought it completely through but I think this can be fleshed out
and even support malloc().
--johnathan.a.tainter
More information about the Comp.lang.c
mailing list