[snips]
Hash tables are normally indexed by names. If you have several "b"s in
your hash table, which one will you remove?
Here's a trivial notion:
void b(void);
void a(void)
{
b();
}
The hasher needs to know not b, but where in a to return to. Thus it
gets two pieces of information: the name "a" and the address to return
to. Since it's possible to have more than one entry matching a.hash (due
to recursion), the hasher may proceed as follows:
add:
for i = 0 to max
hash = a.returnaddress.i
if found continue
insert return address to hash.a.returnaddress.i
Net result, you can call from a 1,000 times with the same return address
and still get the "latest" when returning.
Then, you will have a naming schema, that will simulate stack using
timestamps or similar mechanisms...
Fantastic!
Dunno about fantastic, but functional.
Er, so it goes to show you can create implementations which need no stack
whatsoever, neither a hardware stack nor a logical one; all that's
required is a way to add, find and remove caller information.
This is a typical attitude of the regulars here.
That C does _not_ require things that C actually doesn't require? Yes, it
should be the attitude of anyone using C.
1) They say
"C doesn't use a stack. The word is not mentioned in the standard"
Correct.
Objective: Confuse beginners and display pedantic knowledge...
Objective: be correct. C does not require a stack; feel free to show any
such requirement in the standard. You can't, it's not there. Nor is
there need of a stack data structure.
2) When confronted to reality (no implementation exists that doesn't use
a stack
Let's assume for the moment there is no such implementation; so what? Is
there a guarantee somewhere that there *won't* be such an implementation
tomorrow? If so, I can't find it.
and above all, confronted with the stack like structure of
the language itself) they start with
There is no stack-like structure to the language; there is a structure to
the language which necessitates _some_ form of management of return
addresses and the like, but nothing says that has to be a stack.
3) An implementation *could* exist that... etc.
Correct. It could, as there's no guarantee that even if none exist
today, one won't exist tomorrow.
This is similar to their "trap representation", "one's complement" or
"sign magnitude" stuff... Nobody has ever seen those machines, there are
no implementations but
"... an implementation *could* exist" and there they go.
This is why the standard is written the way it is; not to limit the
language to implementations or hardware designs which exist today, but to
make it maximally portable to almost any conceivable design - including
ones with no stacks, with trap representations, ones complement, you name
it.
You believe "C" (whatever you understand with that) doesn't need a
stack?
No, we know this, as there is no such requirement in the standard. If
you feel differently, please show where, in the standard, such a thing is
required.