Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EDT:Language Overview"

Line 1: Line 1:
= Introduction  =
 
 
 
In many ways, EGL is like other programming languages. It includes familiar constructs such as loops and transfers of control. It is built on a set of '''types''', each of which defines the operations that are available for each value of the type. Last, it involves a process for validating source code and for converting the source code into a less abstract form, closer to the runtime need.  
 
In many ways, EGL is like other programming languages. It includes familiar constructs such as loops and transfers of control. It is built on a set of '''types''', each of which defines the operations that are available for each value of the type. Last, it involves a process for validating source code and for converting the source code into a less abstract form, closer to the runtime need.  
  
Line 11: Line 9:
 
Stereotypes are best&nbsp;understood in the context of EGL types and values.<br>
 
Stereotypes are best&nbsp;understood in the context of EGL types and values.<br>
  
== General comments on type and values  ==
+
= General comments on type and values  =
  
 
In general usage, a '''type''' such as integer or string defines a set of values and a set of operations that can be applied to those values. For example, integers are whole numbers that can be added, subtracted, and so forth; and the number 5 is a value of that type.  
 
In general usage, a '''type''' such as integer or string defines a set of values and a set of operations that can be applied to those values. For example, integers are whole numbers that can be added, subtracted, and so forth; and the number 5 is a value of that type.  
Line 47: Line 45:
 
<pre>  // An invalid assignment
 
<pre>  // An invalid assignment
 
   MINIMUMNUMBERS = [1,2,3,4,5]; </pre>
 
   MINIMUMNUMBERS = [1,2,3,4,5]; </pre>
== EGL native types  ==
+
= EGL native types  =
  
 
EGL Core defines a set of '''native types''', which are implemented only by extensions such as&nbsp;Eclipse IDE for EGL Developers.&nbsp;The most elemental are the '''simple&nbsp;types'''. They have no sub-fields and can be categorized as follows:  
 
EGL Core defines a set of '''native types''', which are implemented only by extensions such as&nbsp;Eclipse IDE for EGL Developers.&nbsp;The most elemental are the '''simple&nbsp;types'''. They have no sub-fields and can be categorized as follows:  
Line 64: Line 62:
 
*Dictionary type, which is the basis of a dictionary. A dictionary is composed of key-value<br>pairs that can be increased or decreased in number and otherwise updated at run time.
 
*Dictionary type, which is the basis of a dictionary. A dictionary is composed of key-value<br>pairs that can be increased or decreased in number and otherwise updated at run time.
  
== EGL classifiers and custom types  ==
+
= EGL classifiers and custom types  =
  
 
EGL provides a variety of '''classifiers''', each of which is a kind of type. The capabilities of a classifier are made available to your code in various situations; most often, when you define a custom type that is based on&nbsp;a classifier.  
 
EGL provides a variety of '''classifiers''', each of which is a kind of type. The capabilities of a classifier are made available to your code in various situations; most often, when you define a custom type that is based on&nbsp;a classifier.  
Line 81: Line 79:
 
== Kinds of classifiers  ==
 
== Kinds of classifiers  ==
  
The next sections explore the EGL classifiers, which are&nbsp;provided in EGL Core.&nbsp;
+
The next sections explore the EGL classifiers, which are&nbsp;provided in EGL Core.&nbsp;  
  
 
To extend a capability,&nbsp;an extender makes an additional stereotype&nbsp;available for use with an existing classifier. The list itself is a fixed aspect of the language. <br>
 
To extend a capability,&nbsp;an extender makes an additional stereotype&nbsp;available for use with an existing classifier. The list itself is a fixed aspect of the language. <br>
  
 
{| border="2" cellspacing="2" cellpadding="2" width="80%"
 
{| border="2" cellspacing="2" cellpadding="2" width="80%"
|+ Kinds&nbsp;of classifiers
+
|+ Kinds&nbsp;of classifiers  
 
|-
 
|-
| &nbsp;&nbsp;&nbsp;&nbsp;'''&nbsp;&nbsp; Name&nbsp;&nbsp;&nbsp;&nbsp;'''
+
| &nbsp;&nbsp;&nbsp;&nbsp;'''&nbsp;&nbsp; Name&nbsp;&nbsp;&nbsp;&nbsp;'''  
 
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '''Purpose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''
 
| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '''Purpose&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''
 
|-
 
|-
| Class
+
| Class  
 
| To provide the Any, Dictionary, and List types.
 
| To provide the Any, Dictionary, and List types.
 
|-
 
|-
| DataItem
+
| DataItem  
 
| To alias&nbsp;a native or custom type.
 
| To alias&nbsp;a native or custom type.
 
|-
 
|-
| Delegate
+
| Delegate  
 
| To define a type that identifies&nbsp;a kind of&nbsp;function.&nbsp;The related variable is like&nbsp;a function pointer in C language.
 
| To define a type that identifies&nbsp;a kind of&nbsp;function.&nbsp;The related variable is like&nbsp;a function pointer in C language.
 
|-
 
|-
| Enumeration
+
| Enumeration  
 
| To define a type that holds a collection of named values. The value of the related variable is one of those values.&nbsp;
 
| To define a type that holds a collection of named values. The value of the related variable is one of those values.&nbsp;
 
|-
 
|-
| ExternalType
+
| ExternalType  
 
| To define&nbsp;a type&nbsp;that&nbsp;identifies non-EGL code. The related variable provides access to the code.
 
| To define&nbsp;a type&nbsp;that&nbsp;identifies non-EGL code. The related variable provides access to the code.
 
|-
 
|-
| Handler
+
| Handler  
 
| To define a type that&nbsp;includes all the possible kinds of members. The related variable either defines a general purpose object or allows for interaction with a user interface technology.
 
| To define a type that&nbsp;includes all the possible kinds of members. The related variable either defines a general purpose object or allows for interaction with a user interface technology.
 
|-
 
|-
| Interface
+
| Interface  
 
|  
 
|  
 
|-
 
|-
| Library
+
| Library  
 
|  
 
|  
 
|-
 
|-
| Program
+
| Program  
 
|  
 
|  
 
|-
 
|-
| Record
+
| Record  
 
|  
 
|  
 
|-
 
|-
| Service
+
| Service  
 
|  
 
|  
 
|}
 
|}
  
<br><br><br><br>Class classifier
+
<br><br><br><br>Class classifier  
  
 
*Class classifier<br><br>The Class classifier is the basis of the ANY type, List types and Dictionary type, all of which are reference types. You cannot use the Class classifier to define custom types.&nbsp;Instead, use the Handler classifier.&nbsp;<br>
 
*Class classifier<br><br>The Class classifier is the basis of the ANY type, List types and Dictionary type, all of which are reference types. You cannot use the Class classifier to define custom types.&nbsp;Instead, use the Handler classifier.&nbsp;<br>

Revision as of 22:16, 12 October 2011

In many ways, EGL is like other programming languages. It includes familiar constructs such as loops and transfers of control. It is built on a set of types, each of which defines the operations that are available for each value of the type. Last, it involves a process for validating source code and for converting the source code into a less abstract form, closer to the runtime need.

EGL is special in its reliance on stereotypes, which are declarations used by the software that transforms the source code to another form such as Java or JavaScript.

Stereotypes offer simplicity. First, they ensure that the output created for a source-code element such as "Handler" includes details for a particular use; for example, to be runnable on a full-page web browser. The developer who writes a customized Handler element and declares the appropriate stereotype does not need to know a lot about a browser to write the code. He can rely on the pre-tested logic that an EGL JavaScript generator creates automatically. 

Second, stereotypes provide a way to extend the language. The creation of a new kind of stereotype enables an existing source-code element to have an alternative use. For example, a future stereotype might allow a developer to write a customized Handler element and then to create output for a mobile device that runs under the Android operating system. This alternative option requires that the extender create Java classes that supplement existing logic. 

Stereotypes are best understood in the context of EGL types and values.

General comments on type and values

In general usage, a type such as integer or string defines a set of values and a set of operations that can be applied to those values. For example, integers are whole numbers that can be added, subtracted, and so forth; and the number 5 is a value of that type.

The meaning is much the same in EGL, where every value is “of a type.” The type defines the structure of the value and the set of operations that can be applied to the value.

Types can be categorized in different ways, and we initially distinguish between reference and value types:  

  • A reference type defines an object, which is a value in a memory area that was separately allocated to hold the value. The object is referenced from some logic and is an instance of the type. In this case, the words "value," "object," and "instance" are interchangeable.
  • A value type defines a value that is embedded in an object.

field declaration is a coded statement that declares a value in a memory area. If the value is based on a reference type, the memory area either represents a null or holds an address that points to the value. If the value is based on a value type, the memory area contains the value itself.

A field declaration typically includes an identifier that names the memory area. If the code that embeds the field declaration is allowed to update the area, the identifier is a variable. If the update is disallowed, the identifier is a constant. Later in this overview is a field declaration that does not name a memory area at all. Such a field declaration is said to be anonymous.

Consider the following field declarations:

   // variable declaration
   NumberOfCars INT;    
   
   // constant declaration
   const MINIMUMNUMBER INT = 2; 

The type is each case is INT, which is a value type for four-byte integers. The first statement declares a value variable, the second declares a value constant.

For a second example, you might declare a list of five integers by coding a statement like one of these:

   // variable declaration
   NumberOfVehicles INT[5];

   // constant declaration
   const MINIMUMNUMBERS INT[5] = [1,2,3,4,5];

The type in this case is INT List or INT[], which is a reference type. The first statement declares a reference variable, which means that you can assign a different list to NumberOfVehicles later. Incidentally, you can also change the values inside the list and can change the number of elements.

The second statement declares a reference constant, which means that you cannot assign a different list to MINIMUMNUMBERS. However, even in this case, you can alter the values inside the list and can change the number of elements.

The behavior is consistent because each declaration in the second example identifies a memory area that contains an address of a second memory area. The constant is only constant in the sense that the area identified as MINIMUMNUMBERS must always contain the same address, which refers to the same list. The following, subsequent assignment is not valid even though the values are the same:

   // An invalid assignment
   MINIMUMNUMBERS = [1,2,3,4,5]; 

EGL native types

EGL Core defines a set of native types, which are implemented only by extensions such as Eclipse IDE for EGL Developers. The most elemental are the simple types. They have no sub-fields and can be categorized as follows:

  • Character types 
  • Timestamp types
  • Large object types
  • Numeric types
  • Miscellaneous types:
    • BOOLEAN, which is the basis of a field that contains the logical true or false.
    • ANY, which is the basis of an instance that itself can reference a value of any type.

The following native types are also built into EGL Core for implementation by an extension: 

  • List types, each of which is the basis of a list. A list is a dynamic array: an ordered sequence of elements that can be increased or decreased in number and otherwise updated at run time.
  • Dictionary type, which is the basis of a dictionary. A dictionary is composed of key-value
    pairs that can be increased or decreased in number and otherwise updated at run time.

EGL classifiers and custom types

EGL provides a variety of classifiers, each of which is a kind of type. The capabilities of a classifier are made available to your code in various situations; most often, when you define a custom type that is based on a classifier.

Depending on the classifier, a custom type can have some or all of the following characteristics:

  • A header, which is always required. The header includes the classifier name; the name of the custom type; and, in some cases, a stereotype.
  • The end keyword, which is the last detail in the type definition.
  • A set of members:
    • Fields, each of which is based on a native or custom type.
    • Functions, each of which is a logical unit that is equivalent to a function or method in another language. EGL functions do not embed other functions.
    • Constructors, each of which is a logical unit that creates an instance of a reference type.

The members in a custom type are typically accessible in the same type. However, if you declare a member to be private, the member is protected from external access; it can be accessed only within the same type. If you do not declare a member to be private, it is said to be public.

Kinds of classifiers

The next sections explore the EGL classifiers, which are provided in EGL Core. 

To extend a capability, an extender makes an additional stereotype available for use with an existing classifier. The list itself is a fixed aspect of the language.

Kinds of classifiers
       Name                              Purpose                        
Class To provide the Any, Dictionary, and List types.
DataItem To alias a native or custom type.
Delegate To define a type that identifies a kind of function. The related variable is like a function pointer in C language.
Enumeration To define a type that holds a collection of named values. The value of the related variable is one of those values. 
ExternalType To define a type that identifies non-EGL code. The related variable provides access to the code.
Handler To define a type that includes all the possible kinds of members. The related variable either defines a general purpose object or allows for interaction with a user interface technology.
Interface
Library
Program
Record
Service





Class classifier

  • Class classifier

    The Class classifier is the basis of the ANY type, List types and Dictionary type, all of which are reference types. You cannot use the Class classifier to define custom types. Instead, use the Handler classifier. 
  • Handler classifier

    The Handler classifier is the basis of a custom type that includes all the possible kinds of members. In the absence of a stereotype, the custom type defines an object, for any kind of use.  In the presence of a stereotype, the custom type handles a series of interactions with the user or with other EGL logic, as necessary to support one or another user interface technology. 

    The next table lists the stereotypes that are available for a Handler part.
     
Stereotype Purpose
     -----  To construct an object for general use
BIRTHandler To customize a Business Intelligence and Reporting Tools (BIRT) report, which is a graphically sophisticated output whose structure is based on a pre-specified design file.

For details on BIRT, see
http://www.eclipse.org/birt.



Examples of custom types 

One classifier is Record, which enables you to define a type with multiple fields. For example, you might use this classifier to define a type named CarPolicy:

Record CarPolicy 
   thePolicyID STRING;
   theCarCount INT;
   theDriverCount INT;
end

You can use a type such as CarPolicy to declare a variable named myCarPolicy:

myCarPolicy CarPolicy;

The variable is called a record, and you can now assign values to its fields: 

myCarPolicy.thePolicyID = "ABC123";
myCarPolicy.theCarCount = 2;
myCarPolicy.theDriverCount = 2;

Another classifier is Program. You use this classifier to define a program, which is a static type: a coded unit that runs and is not the basis of a variable. For example, here is the program AssignPolicyValues:

Program AssignPolicyValues

   myCarPolicy CarPolicy;
   const CONSTANT_TWO INT = 2

   function main()
      myCarPolicy.thePolicyID = "ABC123";
      myCarPolicy.theCarCount = CONSTANT_TWO;
      myCarPolicy.theDriverCount = CONSTANT_TWO;
   end
 end  

AssignPolicyValues embeds fields and functions that are program global, which means that they are accessible throughout the type.

Incidentally, EGL documentation often drops the word “type” when referring to a type that is based on a classifier other than Record. For example, AssignPolicyValues is said to be a “program” rather than a “Program type.”


Back to the top