Amiga E

From Bauman National Library
This page was last modified on 21 May 2016, at 23:48.
Amiga E
Paradigm procedural, object-oriented
Designed by Wouter van Oortmerssen
First appeared 1993
Typing discipline weak, dynamic
OS AmigaOS, Windows
Website Amiga E

Amiga E ( or E) - a programming language created by Wouter van Oortmerssen on the Amiga. He has since moved on to develop the SHEEP for the new AmigaDE platform and the CryScript language (also known as DOG) used during the development of Far Cry.

Amiga E is a combination of many features from a number of languages, but follows the original C programming language most closely in terms of basic concepts. Amiga E's main benefits are fast compilation, powerful module system , exception handling, readable source code, flexible type system and Object oriented programming

History

1993: The first public release of Amiga E.

1997: The last version of Amiga E is released (3.3a).

1999: Unlimited compiler executable of Amiga E is released.

1999: Source code of the Amiga E compiler in M68K assembler is released under the GPL.

1999: First version of CreativE is released. Based on Sourcecode of Amiga E.

1999: First version of PowerD is released. (0.01)

2000: First version of YAEC (Yet Another E Compiler) is released. (1.0)2001: Final version of CreativE (2.12.3) is released.

2002: Final version of YAEC is released (2.5d).

2002: First public release of ECX. (1.0)

2003: Final version of PowerD is released. (0.20)

2008: First public release of PortablE. (r1)

2009: First public release of PortablE for Microsoft Windows. (r4)

Language

Data types

E doesn't have a rigid type-system. There is only one basic, non-complex variable type: 32bit type LONG. A special variation of LONG is the PTR type. Defining the variable:

    DEF <var>[:<type>]

The simple types CHAR (8bit) and INT (16bit) may not be used as types for a basic (single) variable. However they may be used as data type to build ARRAYs from, set PTRs to, use in the definition of OBJECTs etc.

ARRAYs are declared by specifying their length (in elements):

    DEF <var><[size]>:ARRAY [OF <type>]

STRINGs similar to arrays, but different in the respect that they may only be changed by using E string functions, and that they contain length and maxlength information, so string functions may alter them in a safe fashion, i.e: the string can never grow bigger than the memory area it is in. LIST is data structure holds a list of LONG variables which may be extended and shortened like STRINGs.

Objects:

    OBJECT <objname> [OF <objname>]
    [PUBLIC|PRIVATE]
        <membername> [ : <type> ]           /* any number of these */
    ENDOBJECT

OF used for object inheritance. PRIVATE and PUBLIC let you declare a section of an object as visible to the outer world or not.

List of supported data formats:

  • decimal (1)
  • hexadecimal ($F1)
  • binary (%011)
  • float (1.0)
  • character ("a")
  • string ('bla')
  • list ([1,2,3]) and typed lists
  • lisp-cell (<a|b>)

Operators

  • math (+ - * /)
  • comparison (= <> > < >= <=)
  • logical and bitwise (AND OR)
  • unary (SIZEOF ` ^ {} ++ -- -)

++ and -- increase and decrease value SIZEOF returns the size of a object {} returns address of a variable ^ access variable by address ` blocks evaluating

  • triple (IF THEN ELSE)
  • structure (.) - access field of object
  • array ([]) - access array element by index
  • float operator (!) - converts between float and integer
  • assignments expressions (:=)
  • sequencing (BUT) - allows two expressions to be written in a construction that allows for only one. Returns value of the second expression
  • dynamic memory allocation (NEW)
  • unification (<=>) - tries to bind variables in right expression to value to make them equal
  • pointer typing (::) - changes type of pointer

Statements

A statement generally stands in its own line, but several of them may be put together on one line by separating them with semicolon, or one may be spread over more than one line by ending each line in a comma ",".

Labels are global-scoped identifiers with a ':' added to them. JUMP <label> continues execution at <label>.

Conditional statement:

    IF <exp>
        <statements>
    [ ELSEIF <exp>           /* multiple elseifs may occur */
        <statements> ]
    [ ELSE ]
        <statements>
    ENDIF

For-statement:

    FOR <var> := <exp> TO <exp> STEP <step> DO <statement>

or:

    FOR <var> := <exp> TO <exp> STEP <step>
        <statements>
    ENDFOR

While-statement

    WHILE <exp> DO <statement>

or:

    WHILE <exp>
        <statements>
    ENDWHILE

Repeat-statement

    REPEAT
        <statements>
    UNTIL <exp>


Loop-statement (infinite)

    LOOP
        <statements>
    ENDLOOP

Select-case-statement

    SELECT <var>
    [ CASE <exp>
        <statements> ]
    [ CASE <exp>
        <statements> ]   /* any number of these blocks */
    [ DEFAULT
        <statements> ]
    ENDSELECT

Increase statement (does not return value)

    INC <var>
    DEC <var>

Void expressions (calculate expression without returning result)

    VOID <exp>

Memory deallocation

    END <var>

Procedures

PROC used to collect statements into your own functions.

    PROC <label> ( <args> , ... ) [OF <object>]
        <statements>
    ENDPROC <returnvalue>, ...

or:

     PROC <label> ( <args> , ... ) [OF <object>] IS <returnvalue>, ...

The [OF <object>] tells the compiler it belongs to the object.

Examples

Hello world

    PROC main()
        WriteF('Hello, World!\n')
    ENDPROC

Towers of Hanoi

    PROC move(n, from, to, via)
        IF n > 0
            move(n-1, from, via, to)
            WriteF('Move disk from pole \d to pole \d\n', from, to)
            move(n-1, via, to, from)
        ENDIF
    ENDPROC    PROC main()
        move(4, 1,2,3)
    ENDPROC

Using objects

    OBJECT a_class
        varA, varP
    ENDOBJECT    -> constructor
    PROC init() OF a_class
        self.varP := 10
    self.varA := 2
    ENDPROC    -> destructor
    PROC end() OF a_class
        -> nothing todo here...
    ENDPROC    -> a not so useful getter
    PROC getP() OF a_class IS self.varP    PROC main()
        DEF obj : PTR TO a_class
        NEW obj.init()
        WriteF('\d\n', obj.varA)   
        WriteF('\d\n', obj.varP) 
        WriteF('\d\n', obj.getP())
        END obj
    ENDPROC

Links