How would one implement a dynamic associative array that could take any number of mixed indices (integers, strings, or both)?
I aim to simulate structures by providing, for example, people[3].location
as syntactical sugar for people[3, "location"]
. How would you recommend representing this kind of array internally?
By the way, I am using C, and for portability reasons I can only use the standard libraries.
Thanks for your suggestions!
Edit: Just to clarify, I'm asking how one would implement a dynamic associative array with mixed indices for a programming language interpreter written in C. The interpreter in question is actually Yabasic, but that is not particularly relevant.
Edit: Changed to use []
for array syntax rather than ()
.