10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

VariablesOpenROAD checks references to attributes by name and produces compilererrors if the variable's class does not contain those attributes, for example:/* Declarations */a = addr;b = addr;tmp_char = varchar(30);/* Some valid references */a.street = tmp_char;tmp_char = a.city;/* Some invalid references */a.province; /* ERROR at compile time** because attribute 'province'** is not defined for class 'addr' */a = null;a.street;/* ERROR at runtime because 'a' is** null, and does not reference** an object*/Null Reference VariablesWhen you declare a reference variable without specifying default null, thevariable points to an object that is automatically initialized with the defaultvalues given in the definition of the object. However, you can set a referencevariable to null. A reference variable that is set to null does not point to anyobject. Whenever all reference variables for an object are redirected or set tonull, OpenROAD frees the associated object, for example:/* Declarations */a = addr;b = addr;a = b;/* The original object for a is** freed; both a and b point to the** same object */a = null; /* The object still has 1** reference (b) */b = null: /* The object is freed */As an alternative, you can specify default null on the declaration and a defaultobject is not created.You can check for a null reference variable with the is null operator, forexample:if addr is null then/* processing statements */endif;For more information about null reference variables, see Nulls in Expressions(see page 49).30 <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!