Skip to main content Skip to navigation

Data structures

There are 8 different data types, as follows (integer and character types are sometimes collectively called integral type.

@ (undefined)

The constant @ (undefined, similar to the ``bottom'' of some algebras) is a special value. It has a unique (un-named) data type. Some operators, such as arithmetic operators accept @ as their operands, and usually @ will be returned. Other operators which do not take @ operands will generate an error.

Integer

An integer can be specified using one of three formats.

Decimal Integer Constants

A decimal integer constant is a stream of digits with non-leading zero, for example:

123valid
A123invalid (begins with non-digit)
0123invalid (begins with zero but is a valid octal)

Octal Integer Constants

An octal integer constant is a stream of digits with a leading zero. The digits 8 and 9 have octal values 10 and 11 respectively. For example:

0456valid (= 302 decimal)
018valid (= 020 octal = 16 decimal)
456invalid (but is a valid decimal)
A456invalid (begins with non-digit)

Hexadecimal Integer Constants

An hexadecimal integer constant is a stream of hexadecimal digits starting with 0x (zero followed by the character x). Letters A to F have the hexadecimal values 10 to 15 respectively. Lowercase letters a to f are equivalent to their corresponding uppercase letters, for instance:

0xABvalid (= 171 decimal)
0x1fvalid (= 31 decimal)
ABinvalid (begins with an alphabet letter)
01finvalid (missing x)

Character

A character constant is a character enclosed in single quotes, as in 'x'. The value of a character constant is the numerical value of the character in the machine's character set, for example:

'A'valid (value is 65 for the ASCII character set)
'AB'invalid (more than one character)

Certain special characters, such as the single quote ' and the backslash \, may be represented according to the following table of escape sequences:

newlineNL(LF)'\n'
horizontal tabHT'\t'
backspaceBS'\b'
carriage returnCR'\r'
form feedFF'\f'
backslash\'\\'
single quote''\''
double quote"'\"'
nullNUL'\0'
bit patternddd'\ddd'

The escape \ddd consists of the backslash followed by a stream of octal digits which are taken to specify the value of the desired character. If the character following a backslash is not one of those specified, the backslash is ignored.

Floating Point

A floating point constant consists of an integer part, a decimal point, a fraction part, and an exponent part; where an exponent part is an e or E, and an optionally signed integer exponent. The integer and fraction parts both consist of a sequence of digits. Either the integer part or the fraction part (not both) may be missing; either the decimal point or the e (E) and the exponent (not both) may be missing.

Note that a floating point constant may not contain any embedded blanks or special characters.

Some floating point constants are:

1.23
.23
0.23
1.
1.0
1.2e10
1.23e-15

but not

1,000.00comma not allowed
1 000.00embedded space not allowed
1000decimal point or exponential part needed
.e0integer part or fractional part needed
-3.14159this is a floating point expression, not a constant

String

A string constant is a character sequence enclosed in double quotes:

"this is a string"

The backslash convention for representing special characters can also be used within a string. This makes it possible to represent the double quote and the escape character backslash \ within a string. It is not possible for a string to contain the \0 (NUL) character since it is used to represent the end of string internally. Therefore,

"this is the end\0here we passed the end of string"

is equivalent to

"this is the end"

If s denotes a string expression, and i an index (an integer expression) then s[i] denotes the ith character in the string.

An individual character of a string can be accessed randomly by giving the index - an integer expression enclosed in [] - after the string expression. The first character is numbered 1 (not zero). For example, if

s = "abcdef";

then

s[1]is the first character of s, i.e. 'a'.
s[i]is the ith character of s.

It is illegal to index beyond the current number of characters in a string. So s[7] is an error since s has only six characters. The suffix operator # returns the current number of characters in the string. In the last example, s# is 6. For the empty string, ""# is 0.

Pointer

A pointer is the address of an object in the memory space. The prefix operator & gets the address of an object. For example,

iptr = & int_variable;
cptr = & s[5];    /* if s is a string, cptr points to the 5th char of s */

The prefix operator * refers to the object which the pointer is pointing to. For example,

i = * iptr ;    /* i = int_variable; */
c = * cptr ;    /* c = s[5]; */

There are no pointer constants, and no pointer operations except the pointer equality checks.

List

The list is the only structured data type in Eden. Data items of different types can be grouped to form a list using the list formation operator []. Commas are used to separate the data. The whole list is considered as a single data item. For example, the list

[ 100, 'a', "string", [1,2,3] ]

holds four items: an integer (100), a character ('a'), a string ("string") and a list ([1,2,3]).

There are no list constants in the language. The characteristics of the list data type are:

  • Different typed data can be stored in the same list. For instance,
    L = [ 100, 'a', "string", [1,2,3] ];
    
    L holds four items: an integer (100), a character ('a'), a string ("string") and a list ([1,2,3]).
  • The individual items of a list can be accessed randomly by giving the index (an integer expression quoted by []) after the list. The first item is numbered 1 (not zero). For example,
    L[1]is the first item of L, i.e. 100 (in the previous example).
    L[4][2]is 2
  • It is illegal to index beyond the current number of items of a list. So L[5] is an error since L has only four items.
  • The suffix operator # returns the current number of items in the list. In the last example, L# is 4, and L[4]# is 3. For the empty list, []# is 0.
  • The infix operator // returns the concatenated list of two lists; for example,
    [1,2,3] // [5,6,7]
    
    produces
    [1,2,3,5,6,7]
    
  • List-related statements are: append, insert, delete and shift statements.
  • There are no list constants.

Function

Eden allows the user to define functions (or procedures). There are also pre-defined functions, such as write, writeln, and exit.