Simply put C can do this by running two (or more) programs that constantly modify and recompile one another. Thus anything that is possible at write-time is possible at run-time by utilizing this technique. Efficiency is another question.
Name:
Anonymous2011-12-05 10:30
>>2
Not sure what you mean, but I'll do some googling
>>6
Black magic is best magic. I bet you can pull of some wizardry with an array of dynamically-sized arrays, each of which represents an object, using an hash table to identify each sub-array. The type of a variable can be encoded into the last few bits of every variable in each sub-array.
It probably won't work very well, but it sounds fun.
>>9
afters hours of segfaults, stackdumps, random bugs,wtf-logic
you can into wizardry (aka 'achieve satori') or instanity, not that normalfags can tell the difference
Can you please sage posts in threads that are on the first page and are not a major contribution? This is the board's culture and I'd appreciate it if you respected it. Thanks.
>>22 The hard part is keeping track of what's stored where. Sure, mapping a few symbols or numbers to pointer is ``hard''.
Name:
Anonymous2011-12-06 2:50
A struct serves a mapping from member names to values in the struct. In C, a struct is efficiently implemented as a block of memory that has been reserved, say of size n bytes. There is an associated mapping from member names to offsets in the struct: f: {names} -> {offsets}. When you use structs in C, the function f is defined at compile time, and it is applied to the member names at compile time to determine offsets into a struct to be used at runtime. If you would like to dynamically create and use structure definitions at run time, then you will need to manage the mapping, f with some kind of implementation that will exist at run time. Basically, you are asking if it is possible to have a data structure where given string keys, you can get values. And yes, there are many choices you can use for this, like hash maps, or trees. You could try to compactify the data structure into something like a C struct, where you have a chunk of memory with offsets into it reserved for certain values. You could then manage the size of the block of memory and the mapping to the offsets using another data structure, or maybe a function. If you wanted to, you could say that an array is like a struct, but the member variable names are numbers, instead of strings.