update internals 3

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...


... back to index page OE documentation

the system for reuse.

postfill The size of 'post fill space' in element spaces. Rather than using bytes, postfill is measured in objects which are each address wide elements. If this is non-zero, we can append to the sequence with at most postfill new elements before needing to reallocate RAM.
cleanup If not null, it points to a routine that is called immediately before the sequence is deleted.
pre fill space There are 0 or more spaces before base[1]. We can calculate the free space in *objects* at the front of a sequence, s1, in C by
(&s1.base[1] - (object_ptr)(1+&s1)).
In EUPHORIA, you will have to divide by the size of a C_POINTER on the difference. When elements are removed from the front of a sequence, we simply adjust the address in base to point to the new first element and reduce the length count. If we want to prepend and this pre fill space has some positive size, then we make room by decrementing base and increment the length. The new data is then assigned to base[1].
base[1]..base[length] sequence data This is actual data.
base[$+1] This is always set to NOVALUE.
post fill space There are 0 or more spaces after base[length+1]. The number of spaces is stored in postfill. If postfill is non-zero we can append by incrementing the length, decrementing postfill and assigning the new data to base[$]. When we remove from the end of the sequence, we increment postfill and decrement the length.

// Atom Header 
struct d 
 double dbl;          // the actual value of a double number. 
 long ref;            // ref is the number of virtual copies of this double 
 cleanup_ptr cleanup; // this is a pointer to a Euphoria routine that is run  
                      // just before the sequence is freed. 

Now offset of the 'ref' in struct d must be the same as the offset of the 'ref' in struct s1. To this end, the 64bit implementation of 4.1 has these members in a different order.

The Euphoria Object Macros and Functions


The macros are imperfect. For example, IS_SEQUENCE(NOVALUE) returns TRUE and IS_ATOM_DBL will return TRUE for integer values as well as encoded pointers to 'struct d's. This is why there is an order that these tests are made: We test IS_ATOM_INT and if that fails we can use IS_ATOM_DBL and then that will only be true if we pass an encoded pointer to a double. We must be sure that something is not NOVALUE before we use IS_SEQUENCE on it.

Often we know foo is not NOVALUE before getting into this:

// object foo 
if (IS_ATOM_INT(foo)) { 
 // some code for a Euphoria integer 
} else if (IS_ATOM_DBL(foo)) { 
 // some code for a double 
} else { 
 // code for a sequence foo 

A sequence is held in a 'struct s1' type and a double is contained in a 'struct d'.

Type Value Functions and Macros

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu