Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: TUPLE! DATA-MODEL & OTHER VALUES

From: karlr20:home at: 13-Jun-2001 10:36

> It seems like there are about 16 bytes allocated per element when the empty > block is created, but when I insert 10000 decimal! values at a minimum of 8 > bytes per element into it, the memory allocation does not increase. > > Does this imply the "pointers" for the block elements have room somewhere > for short simple types, or does the block creation simply allocate a > certain amount of space for short simple values? > > Are the values of simple block elements stored consecutively in memory, or > does the block just contain "pointers" to values in the heap? > > Any comments would be much appreciated. > > -Larry
Hi Larry, I've written a C++ class to read REBOL code as values and now my own REBOL-like language. I'm pretty sure I have a handle on how REBOL stores values. My basic value is something like this: struct Value { DatatypeReference type; union data { int integer; double decimal; bool logic; char tuple[10]; Block* block; String* string; // etc... }; }; For REBOL the sizeof(Value) seems to be 16 bytes. As you can see, adding any simple data type to a block (array of Values) will not increase its size as the data is stored in the value. I hope this helps you to visualize what may be going on. -Karl P.S. Opps, I just realized I have assumed you are a C programmer!