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"

 
(123 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= Introduction  =
+
<span style="font-size:smaller;">&lt;&nbsp;[[EDT| EDT wiki home]]</span>
 +
 
 +
This overview introduces the EGL language as&nbsp;defined&nbsp;in EGL Core and as extended&nbsp;by Eclipse IDE for the EGL Web Developer.&nbsp;Reference details are in the EDT help system, which is made available when you install a download from the following site:&nbsp; [http://www.eclipse.org/edt/download/ www.eclipse.org/edt/download/].
  
 
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 5: Line 7:
 
EGL is special in its reliance on '''stereotypes''', which are declarations used by the software that&nbsp;transforms the source code to another form such as Java or JavaScript.  
 
EGL is special in its reliance on '''stereotypes''', which are declarations used by the software that&nbsp;transforms the source code to another form such as Java or JavaScript.  
  
Stereotypes&nbsp;offer simplicity. First,&nbsp;they ensure&nbsp;that the&nbsp;output&nbsp;created for a&nbsp;source-code&nbsp;element such as&nbsp;"Handler" includes details for a particular use;&nbsp;for example, to be runnable on a&nbsp;full-page web browser.&nbsp;The developer who&nbsp;writes a customized Handler element and declares the appropriate&nbsp;stereotype does not need to know a lot about a browser to write&nbsp;the code. He can rely on&nbsp;the pre-tested&nbsp;logic that an EGL JavaScript generator creates automatically.&nbsp;  
+
Stereotypes&nbsp;offer simplicity. First,&nbsp;they ensure&nbsp;that the&nbsp;output&nbsp;created for a&nbsp;source-code&nbsp;element such as&nbsp;"Handler" includes details for a particular use;&nbsp;for example, to be runnable on a&nbsp;full-page web browser.&nbsp;The developer who&nbsp;writes a custom Handler element and declares the appropriate&nbsp;stereotype does not need to know a lot about a browser to write&nbsp;the code. He can rely on&nbsp;the pre-tested logic that is created by an EGL JavaScript generator.&nbsp;The pre-tested&nbsp;logic&nbsp;supplements the custom logic.&nbsp;&nbsp;&nbsp;  
  
Second, stereotypes provide a way to extend the language.&nbsp;The creation of a&nbsp;new kind of stereotype&nbsp;enables an existing source-code element&nbsp;to have an&nbsp;alternative use. For example, a&nbsp;future stereotype might allow a developer to write a customized Handler element and then to&nbsp;create output for a mobile device that&nbsp;runs under&nbsp;the Android operating system. This alternative&nbsp;option requires that the extender&nbsp;create Java classes that supplement existing logic.&nbsp;  
+
Second, stereotypes provide a way to extend the language.&nbsp;The creation of a&nbsp;new kind of stereotype&nbsp;enables an existing source-code element&nbsp;to have an&nbsp;alternative use. For example, a&nbsp;future stereotype might allow a developer to write a custom Handler element and then to&nbsp;create output for a mobile device that&nbsp;runs under&nbsp;the Android operating system. This alternative&nbsp;option requires that the extender&nbsp;create Java classes that&nbsp;add to the&nbsp;existing generator logic.&nbsp;  
  
Stereotypes are best&nbsp;understood in the context of EGL types and values.<br>
+
The mechanism for using stereotypes is provided by&nbsp;EGL Core, which includes the&nbsp;basic rules of EGL syntax.&nbsp;Most stereotypes are provided by an EGL extension, and the first extension is Eclipse IDE for the EGL&nbsp;Developer.<br>  
  
== General comments on type and values  ==
+
We describe stereotypes in the&nbsp;first of&nbsp;the following pages and&nbsp;proceed to&nbsp;other aspects of the language:&nbsp;<br>
  
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.
+
*[[EDT:Language Overview02|EGL types and values]]
 +
*[[EDT:Language Overview03|Packages and type-name resolution]]
 +
*[[EDT:Language Overview04|Syntax and scope]]
  
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.
+
<br> <br>
  
Types can be categorized in different ways, and we initially distinguish between&nbsp;reference&nbsp;and value types:&nbsp;&nbsp;
+
&nbsp;  
 
+
*A '''reference type''' defines an '''object''', which is a value in a memory area that was separately allocated to hold&nbsp;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.
+
 
+
A&nbsp;'''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&nbsp;an address&nbsp;that&nbsp;points&nbsp;to the value. If the value is based on a value type, the memory area contains the value itself.
+
 
+
A field&nbsp;declaration typically includes an identifier that names the memory area.&nbsp;If the code that embeds the field declaration&nbsp;is allowed to&nbsp;update the area, the identifier is a '''variable'''.&nbsp;If&nbsp;the update is disallowed, the identifier is a '''constant'''. Later in this&nbsp;overview&nbsp;is a&nbsp;field declaration that does not name a&nbsp;memory area at all. Such a field declaration is said to be&nbsp;'''anonymous'''.
+
 
+
Consider the following&nbsp;field declarations:
+
<pre>&nbsp;&nbsp;&nbsp;// variable declaration
+
&nbsp;&nbsp; NumberOfCars INT;&nbsp;&nbsp;&nbsp;&nbsp;
+
&nbsp;&nbsp;
+
&nbsp;&nbsp; // constant declaration
+
&nbsp;&nbsp; const MINIMUMNUMBER INT = 2; </pre>
+
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:<br>
+
<pre>  // variable declaration
+
  NumberOfVehicles INT[5];
+
 
+
  // constant declaration
+
  const MINIMUMNUMBERS INT[5] = [1,2,3,4,5];</pre>
+
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 <code>NumberOfVehicles</code> 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 <code>MINIMUMNUMBERS</code>. 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 <code>MINIMUMNUMBERS</code> 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:<br>
+
<pre>  // An invalid assignment
+
  MINIMUMNUMBERS = [1,2,3,4,5]; </pre>
+
== 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:
+
 
+
*Character types&nbsp;
+
*Timestamp types
+
*Large object types
+
*Numeric types
+
*Miscellaneous types:<br>
+
**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:&nbsp;
+
 
+
*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<br>pairs that can be increased or decreased in number and otherwise updated at run time.
+
 
+
== EGL classifiers  ==
+
 
+
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 the classifier.
+
 
+
Before we list the classifiers, we consider the characteristics of the custom types and offer&nbsp;examples.
+
 
+
=== Characteristics of&nbsp;custom types<br> ===
+
 
+
Depending on the classifier, a custom type&nbsp;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&nbsp;some cases, a stereotype.
+
*The '''end''' keyword, which is the&nbsp;last&nbsp;detail in&nbsp;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.<br>
+
 
+
=== Examples of custom types&nbsp;  ===
+
 
+
One classifier is Record, which&nbsp;enables you to define a type with multiple fields. For example, you might use this classifier to define a type&nbsp;named <code>CarPolicy</code>:
+
<pre>Record CarPolicy
+
  thePolicyID STRING;
+
  theCarCount INT;
+
  theDriverCount INT;
+
end</pre>
+
You can use a type&nbsp;such as <code>CarPolicy</code> to declare a variable named <code>myCarPolicy</code>:
+
<pre>myCarPolicy CarPolicy;</pre>
+
The variable is called a '''record''', and you can now assign&nbsp;values to&nbsp;its fields:&nbsp;
+
<pre>myCarPolicy.thePolicyID = "ABC123";
+
myCarPolicy.theCarCount = 2;
+
myCarPolicy.theDriverCount = 2;</pre>
+
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.&nbsp;For example, here is the program <code>AssignPolicyValues</code>:
+
<pre>Program AssignPolicyValues
+
 
+
  myCarPolicy CarPolicy;
+
  const CONSTANT_TWO INT = 2
+
 
+
  function main()
+
      myCarPolicy.thePolicyID = "ABC123";
+
      myCarPolicy.theCarCount = CONSTANT_TWO;
+
      myCarPolicy.theDriverCount = CONSTANT_TWO;
+
  end
+
end&nbsp; </pre>
+
<code>AssignPolicyValues</code> embeds&nbsp;fields and functions that&nbsp;are '''program global''', which means that they are accessible throughout the type.
+
 
+
The members in a&nbsp;custom type&nbsp;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'''.
+
 
+
Incidentally, EGL documentation&nbsp;often drops the word “type” when referring to a type that is based on a classifier other than Record. For example, <code>AssignPolicyValues</code> is said to be a “program” rather than a “Program type.”
+
 
+
<br>
+
 
+
<br>
+
 
+
<br>Kinds of classifiers
+
 
+
<br>The classifiers&nbsp;in EGL Core are as follows:&nbsp;
+
 
+
<br>
+
 
+
<br>&nbsp;  
+
  
 
&nbsp;  
 
&nbsp;  
  
<br>
+
[[Category:EDT]]
 
+
<br>
+
 
+
<br>
+

Latest revision as of 10:41, 10 July 2012

EDT wiki home

This overview introduces the EGL language as defined in EGL Core and as extended by Eclipse IDE for the EGL Web Developer. Reference details are in the EDT help system, which is made available when you install a download from the following site:  www.eclipse.org/edt/download/.

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 custom 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 is created by an EGL JavaScript generator. The pre-tested logic supplements the custom logic.   

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 custom 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 add to the existing generator logic. 

The mechanism for using stereotypes is provided by EGL Core, which includes the basic rules of EGL syntax. Most stereotypes are provided by an EGL extension, and the first extension is Eclipse IDE for the EGL Developer.

We describe stereotypes in the first of the following pages and proceed to other aspects of the language: 



 

 

Back to the top