dj Type DJFieldDeclarator, ..., DJFieldDeclarator;where the Type must be either an attribute type, a base class, or a user-defined DJ class, and each DJFieldDeclarator takes one of the following forms:
Identifier (1) Identifier in Domain (2) Identifier R expression (3) Identifier ConstraintBlock (4)where (2), (3), and (4) specify some constraints on the dj-field. Declarator (2), where Domain is an integer interval l..u or a list of values
==, !=, >, >=, <, <=
), says that the dj-field and expression satisfy the relation R. Declarator (4), where ConstraintBlock is a sequence of constraints in the form:
{Constraint; ...; Constraint}says that the dj-field satisfies the constraints.
The following shows three examples:
dj int w == rect.width; dj Color color in {red,black,white}; dj int x in 0..9;The first one declares an attribute, named width, and constrains it to be the same as rect.width where rect must be a component declared in the same class. The other two examples declare two attribute variables and specify their domains. Here are three more examples:
dj Rectangle rect1, rect2{size == rect1.size}; dj Label hw{text == "Hello World!"}; dj Button bt{text == "Button"; x == y};The first one declares two rectangles that have the same size; the second one declares a label whose text is "Hello World!"; and the third one declares a button whose x-y coordinates are the same.