Quick Start with Elisa  

Using Development System Demo's


Language Description

1. Lexical Elements
2. Basic Data Types and Expressions
3. Definitions
4. Streams
5. Backtracking
6. Statements and Special Expressions
7. Arrays

8. Lists
9. Descriptors
10. Components
11. Collections
12. Generic Components
13. Terms
14. Categories
15. Types 

16. Built-in Definitions
17. Higher-order Definitions

18. External Interfaces


Data Structures

1. Sequences
2. Examples involving Lists
3. Trees
4. Graphs
5. Searching State Spaces
6. Language Processing
7. Knowledge Representations          



1. Multi-value Functions

2. Lists and Streams

3. Descriptors

4. Trees


Back Home Up Next


9.1 Descriptor Types
9.2 Descriptor Layout
9.3 Descriptor Creation
9.4 Selecting Descriptor Elements
9.5 Summary

Descriptors are used to describe concrete or abstract real world entities such as persons, cars, insurance policies, weather conditions, and so on. These kinds of entities are often described in terms of attributes or properties, like size, age, or color. Therefore a descriptor is a composite data structure with named elements that are used to characterize the attributes and properties of an entity. This chapter explains the concepts of descriptors and how to use them.


9.1 Descriptor Types

Each descriptor is of a user-defined type. Descriptors of the same type have the same structure. User-defined types are simply introduced by so-called descriptor-type-specifications. For example, the user may introduce the concept of an employee by specifying:

type Employee;

From now on, Employee is known as the name of a new descriptor-type.


9.2 Descriptor Layout

A descriptor is a data structure consisting of a fixed number of elements. Each element has a name, a type and a single value. The name of an element should be unique within the descriptor. The types of the elements in a descriptor may be different. The descriptor type is associated with the descriptor. The layout of the descriptor is described by a so-called descriptor constructor. For example, the descriptor constructor for an Employee may be:

Employee:[ Name= PersonsName; Hiredate= Date; Salary= Amount ]

A descriptor constructor starts with the name of the descriptor type, followed by a colon, followed by a list of elements within square brackets and separated by semicolons. In our example, an Employee-descriptor has three elements: Name, Hiredate, and Salary.


9.3 Descriptor Creation

A new descriptor is created by the evaluation of the descriptor-constructor. A descriptor-constructor is a special kind of expression. Its evaluation results in the creation of a corresponding descriptor and in the assignment of the specified values to its elements.

This means that in our example, after the creation of the Employee-descriptor, the PersonsName will be assigned to the Name element, that Date will be assigned to the Hiredate and that Amount will be assigned to the Salary element. Furthermore, Name will get the type of PersonsName, Hiredate will get the type of Date, and Salary will get the type of Amount.

Often, a descriptor-constructor is embedded in a function-definition. Such a function is called a constructor function, as in:

NewEmployee (Name= text, Date= text, Salary= integer) -> Employee;
NewEmployee (PersonsName, Date, Amount) =
	  Employee:[ Name=PersonsName; Hiredate=Date; Salary=Amount ];

Each call of NewEmployee will now result in the creation of a new Employee-descriptor, as will be shown in the following dialogue:

John = NewEmployee ( "John Smith", "3-7-90", 10000);
Employee:[ Name = "John Smith";
           Hiredate = "3-7-90"; 
           Salary = 10000];

In this dialogue, the user first introduces a new employee, John Smith, by calling the NewEmployee constructor function. The name John is assigned to the resulting descriptor.

The following step from the user is to ask for John. The system returns a textual representation of the Employee descriptor associated with John.

The dialogue session may be continued in the following way:

Mary = NewEmployee ( "Mary Ford", "9-4-91", 15000);
Employee:[ Name = "Mary Ford";
           Hiredate = "9-4-91"; 
           Salary = 15000];

In our example we used in the descriptor-constructor element definitions such as Name = PersonsName. In many cases, however, it is more convenient to use a single name as a short-hand notation for an element. Such a single name must refer to an existing name. If such a name is used then the element's name, type and value are copied from the referred name. So, our example can be rewritten, without any change in functionality, as:

NewEmployee (Name= text, Date= text, Salary= integer) -> Employee;
NewEmployee (Name, Hiredate, Salary) = Employee:[ Name; Hiredate; Salary ]; 

The elements Name, Hiredate and Salary are receiving their names, types and values from the corresponding parameters.

In practical applications, both the Name and the Hiredate are itself again descriptors, representing composite data structures. For example, Name may be composed of First Name, Middle Name, and Last Name. We will show later on, how descriptors of a given type can be used as elements of other descriptors. Also arrays and lists may be used as elements of descriptors. On the other hand, descriptors may also be used as elements of arrays and lists.


  • 9.1 Make a constructor function for Name which is composed of First Name, Middle Name, and Last Name.


9.4 Selecting Descriptor Elements

An element of a descriptor is selected by placing a period between the name of the descriptor and the name of the element. For example, to select the Salary of John, we may write:


Instead of John, we may also write an expression which represents John, or in a more general case, an expression which represents an Employee. We say that the element name is qualified by the descriptor expression. Suppose we want to ask for the Salary of any Employee, by means of a function:

ShowSalary (Employee) -> integer;
ShowSalary (Empl) = Empl.Salary;

We can now ask for the salaries of John and Mary:

ShowSalary (John)?
ShowSalary (Mary)?

If we want to change the salary of an Employee we define:

UpdateSalary (Employee, Increase = integer) -> nothing;
UpdateSalary (Empl, Inc) = [Empl.Salary:= Empl.Salary + Inc];

In the following dialogue the given definitions are used:

UpdateSalary (Mary, 2000);
ShowSalary (Mary)?
UpdateSalary (John, -1000);
ShowSalary (John)?

May be you have noticed that in this chapter three types of definitions were shown:

  • constructors, such as NewEmployee, which are creating new descriptors.
  • accessors, such as ShowSalary, which are retrieving data from descriptor-elements without changing them.
  • mutators, such as UpdateSalary, which are changing values of descriptor-elements.

Later on, we will see more applications of these different kinds of definitions.


  • 9.2 Define an accessor function for Name of Exercise 9.1 to retrieve the Last Name.
  • 9.3 Define a mutator function for changing the First Name of Exercise 9.1.


9.5 Summary

  • Descriptors may be used to describe real world entities. The elements of a descriptor are used to describe attributes or properties. Each element has a name, a type and a single value. The name of an element should be unique within the descriptor. The types of the elements in a descriptor may be different.
  • Constructor definitions are creating new descriptors.
  • Accessor definitions are retrieving data from descriptor-elements without changing them.
  • Mutator definitions are changing values of descriptor-elements.


Top of Page   Part 1: Language Description   Chapter 9: Descriptors




  <!-- Start of StatCounter Code for Default Guide -->
<script type="text/javascript">
var sc_project=11338540;
var sc_invisible=0;
var sc_security="f2d7a14f";
var sc_https=1;
var scJsHost = (("https:" == document.location.protocol) ?
"https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" + scJsHost+
<noscript><div class="statcounter"><a title="Web Analytics Made Easy -
StatCounter" href="http://statcounter.com/" target="_blank"><img
class="statcounter" src="//c.statcounter.com/11338540/0/f2d7a14f/0/"
alt="Web Analytics Made Easy - StatCounter"></a></div></noscript>
<!-- End of StatCounter Code for Default Guide -->