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  =
 
= 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 and values that are available for each instance 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 and values that are available for each instance 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 converts 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 converts 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;simple source-code&nbsp;element such as '''Program''' includes the details needed for a&nbsp;particular&nbsp;use; for example, for execution on a&nbsp;particular runtime platform such as Java Enterprise Edition.&nbsp;The coder who places the stereotype on a customized&nbsp;Program element does not need to know a lot about Java Enterprise Edition. <br><br>Second, stereotypes provide a way to extend the language.&nbsp;The addition of a&nbsp;stereotype&nbsp;enables the&nbsp;same&nbsp;source-code element&nbsp;to have an&nbsp;alternative use; for example, for program execution on a runtime platform such as CICS.  
+
Stereotypes&nbsp;offer simplicity. First,&nbsp;they ensure&nbsp;that the&nbsp;output&nbsp;created for a&nbsp;simple source-code&nbsp;element such as '''Program''' includes the details needed for a&nbsp;particular&nbsp;use; for example, for execution on a&nbsp;particular runtime platform such as Java Enterprise Edition.&nbsp;The developer who includes the stereotype on a customized&nbsp;Program element does not need to know a lot about Java Enterprise Edition.&nbsp;
 +
 
 +
Second, stereotypes provide a way to extend the language.&nbsp;The addition of a&nbsp;stereotype&nbsp;enables the&nbsp;same&nbsp;source-code element&nbsp;to have an&nbsp;alternative use; for example, for program execution on a runtime platform such as CICS.  
  
 
== Types and values  ==
 
== Types and values  ==
Line 22: Line 24:
 
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 holds an address&nbsp;that either points&nbsp;to the value or represents a&nbsp;null. If the value is based on a value type, the memory area contains the value itself.  
 
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 holds an address&nbsp;that either points&nbsp;to the value or represents a&nbsp;null. 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 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'''.  
+
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 all 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'''.  
  
 
Turning now to EGL syntax, consider the following&nbsp;field declarations:  
 
Turning now to EGL syntax, consider the following&nbsp;field declarations:  

Revision as of 13:33, 12 October 2011

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 and values that are available for each instance 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 converts the source code to another form such as Java or JavaScript.

Stereotypes offer simplicity. First, they ensure that the output created for a simple source-code element such as Program includes the details needed for a particular use; for example, for execution on a particular runtime platform such as Java Enterprise Edition. The developer who includes the stereotype on a customized Program element does not need to know a lot about Java Enterprise Edition. 

Second, stereotypes provide a way to extend the language. The addition of a stereotype enables the same source-code element to have an alternative use; for example, for program execution on a runtime platform such as CICS.

Types 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 programming, 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.

Kinds of types

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 holds an address that either points to the value or represents a null. 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 all 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.

Turning now to EGL syntax, 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 in a later assignment. 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 in a later assignment. 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]; 

Back to the top