You are here: start » geeny » home » reference » advanced

Runtime Eval Compilation

Objects as Arrays

A database object has similar behavior to an array.

The list, last and count operators may be used directly on a reference:

clear($)           // properties on the object are destroyed 
count $            // 0 
ATOM $.prop1       = 'atom1'
INTEGER $.prop2    = 11 
ATOMS $.prop3      = {'atom2' 'atom3' 'atom4'} 
$[0]               // nul 
$[1]               // 'atom1' 
$[2] = 15.1        // rounds to INTEGER, 15 
$[3][1]            // 'atom2' 
$[3][2]            = 'atom5' 
$.prop3            // {'atom2' 'atom5' 'atom4'} 
$[15]              = 'atom5' //no effect 
last last $        // 'atom4' 
[$[1 .. 3]] = nul  // clear first three properties 
count $            // 3

The names of properties may be read and altered using a system function. This way, the same name may be shared among multiple properties. In such case, regular access to properties by using their name is not guaranteed to always return the first property with that name:

pname($, 1)        // 'prop1' 
pname($, 3, 'prop1') // 1st and 3rd property share the name ‘prop1’ 
$.prop1            // might return either 1st or 3rd 
                   // prop - unpredictable but not random

The type of a property may be read or altered, or a range of properties may be read and altered using an operator and system functions:

$.prop1|type       // 'ATOM' 
$[1]|type          // 'ATOM' 
pdeclare(1, 'INTEGER') // $.prop1 is now INTEGER, value undefined 
pdeclare(1, 'FLOAT') = 0.0 
count $            // 3 
pdeclareset(2, 50, 'ATOM') 
count $            // 50

Functions pname (only when setting, not reading a name), pdeclare and pdeclareset implicitely call presize when the number of properties allocated on the database object is less than required. The newly added properties have no type or name (all names are nul).

presize($, 50)     // items 1 .. 50 may now be accessed 
presize($, 0)      // all properties are deleted, equivalent to clear($)

Reading typeless properties is safe (nul is always returned). Assignment into typeless properties is also safe (no effect).

Invisible Parameters

Array Call

Script Call

Fallback

Logging

Console

Busy Signal

Engine Settings

 
geeny/home/reference/advanced.txt · Last modified: 2015/11/18 07:37 by matija
Recent changes · Show pagesource · Login