Stereotypes

A stereotype is an annotation that you set to communicate a major decision to the EGL compiler; in most cases, to the generator invoked by the compiler. In response to the annotation, the EGL system code creates output that acts stereotypically, that is, in accordance with a pattern. The pattern differs from one stereotype to another.

The difference in generated output is often related to the statements you code. The following example clarifies the idea and includes reference to a stereotype (CSVRecord) that is available only in a commercial product:

In both the preceding examples, the word “type” is an abbreviation for “stereotype.”

To see that a stereotype is a kind of annotation, compare the earlier of MyCSVRecord with the following, equivalent one:
Record MyCSVRecordPart {@CSVRecord {fileName = "employ", delimiter = ","}}
   employeeID INT;
   employeeName STRING;
   salary DECIMAL(7,2);
end
Although the second, longer form is rarely used, the at sign (@) again declares a value used by the EGL system code. In this case, the declaration is based on the CSVRecord Record part, which includes several fields:
Record CSVRecord type Stereotype
   fileName STRING;
   delimiter CHAR(1);
   ...
end
You declare a stereotype only when you define a part. If the part can include fields, the stereotype identifies a set of member annotations, which are annotations that apply to those fields. For example, consider the EmployeeType Record part again:
Record EmployeeType type SQLRecord 
                         { TableNames = [["EMPLOYEE"]], KeyItems = [employeeID] }

   employeeID INT      { Column     = "EMPID" };
   employeeName STRING { Column     = "EMPNAME"};
   salary DECIMAL(7,2) { Column     = "SALARY"};
end

The Column annotation relates the employeeID, employeeName, and salary fields with relational-database table columns; specifically, with the EMPID, EMPNAME, and SALARY columns. The SQLRecord stereotype causes the Column annotation to be available in any Record part that is defined with the stereotype.

Each classifier such as Record or Program supports zero to many stereotypes. You select from the list when you define a custom part.