views:

70

answers:

1

I'm developing an interpreter and I have some questions to it.

I recently saw a small C interpreter that used a very simple struct like the below for all its objects/values in the language:

struct Object
{
    ubyte type;
    ubyte value;
};

This struct can hold strings, integers, bools and lists (I think) used in the language the interpreter is working with.

  • How can you get this Object struct to hold all these types?
+2  A: 

How can you get this Object struct to hold all these types?

It doesn't hold the value it just holds IDs/references to the values which are stored somewhere else.

sbi