[REBOL] Re: TUPLE! DATA-MODEL & OTHER VALUES
From: karlr20:home at: 16-Jun-2001 13:00
On Wednesday 13 June 2001 12:54, you wrote:
> Hi Karl,
>
> You wrote:
> > 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.
>
> Thanks for sharing your insights. BTW do your "values" incorporate, in the
> case of blocks, the current index as described by Holger in his recent
> post.
>
> > -Karl
> >
> >
> > P.S. Opps, I just realized I have assumed you are a C programmer!
>
> Yes, I am familiar with C and C++ although not using them much at the
> present time.
>
> -Larry
No, my blocks do not keep a current index. This is trivial to add, though.
A block could be implemented with this:
struct Block
{
int reference_count;
Value* current_index;
// Like an STL vector<Value>
Value* start;
Value* finish;
Value* end_of_storage;
};
-Karl