[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I'm wrong or Will we fix the ducks limp?

On Tue, Jun 7, 2016 at 4:33 PM, Gregory Ewing
<greg.ewing at> wrote:
> Steven D'Aprano wrote:
>> I think I'm on
>> fairly solid ground to say that a language that is just like C except that
>> it allocates variables in a hash table at runtime, using runtime lookups
>> for variable access, would not satisfy the C89 or C99 standards.
> I wouldn't be so sure about that. Modern C standards are
> pretty careful to avoid making any promises about how
> things are laid out in memory, etc.
> It wouldn't surprise me much if you could come up with
> such an implementation that adheres to the strict letter
> of the standard. It also wouldn't surprise me if that
> implementation failed to run a large proportion of
> real C code out there, though...

Without having read any of the specs, my guess is you could be C89/C99
compliant putting all your "simple variables" into the hash table -
int, char, float, double, etc - but keep all your arrays and structs
in "real memory". There's no reason a CPU couldn't be built with fifty
million registers available, and the compiler could just put all those
scalars into registers (assuming you never take their addresses, in
which case they then need to have them).