Getting Started with Elisa

Using EDS




Language Description

1. Lexical Elements
2. Basic Data Types and Expressions
3. Definitions
4. Streams
5. Backtracking
6. Statements and Special Expressions
7. Arrays
8. Lists
9. Descriptors
10. Components
11. Collections
12. Generic Components
13. Terms
14. Categories
15. Types 

16. Built-in Definitions
17. Higher-order Definitions

18. External Interfaces


Data Structures

1. Sequences
2. Examples involving Lists
3. Trees
4. Graphs
5. Searching State Spaces
6. Language Processing
7. Knowledge Representations          



1. Introduction
2. What are Domain Definitions?

3.  Sorts of Domain Definitions

4.  Manipulations of Domain Definitions

5.  Translating Domain Definitions

6.  Dialogue Sessions

7.  Example of Concentric Circles

8.  Example of Domain Substitution applied to Concentric Circles

9.  Example of an Order Processing Application

10.Example of an Airport Information System

11.Example of a Rental Boat Business

12.Benefits of Domain Definitions


Back Home Up Next


18.1 Foreign declarations

18.2 Calling Sequences

18.3 Strings in C

18.4 Arrays in C

18.5 Examples

The Elisa language provides facilities to acces external functions written in other programming languages. The current implementation of Elisa is restricted to external routines written in C. 

18.1 Foreign declarations 

A foreign declaration specifies an external function. The general form of a foreign declaration is:

foreign(c) signature;

The signature specifies the name, the number and the types of the parameters, and the result specification of the external function. The result specification may not contain the quantifiers optional and multi.

As an example, the following declaration: 

foreign(c) sin(real) -> real;

specifies that the sin(real) -> real is an external C function.

A call in an Elisa program of


 will execute the corresponding C function and will return the value of sin(x)    

Other examples are:  

type double = subtype(real);
foreign(c) sin(double) -> real;
foreign(c) cos(double) -> real;
foreign(c) atan(double) -> real;
foreign(c) log(double) -> real;
foreign(c) exp(double) -> real;

18.2 Calling Sequences

A C function has a calling sequence which is different from a calling sequence in Elisa. Also the implementation of arguments is different. Here is an overview of the basic data types as illustrated by the following table:




character char 1 byte
boolean not defined 1 byte
integer  long 4 bytes
real double 8 bytes

 As will be clear from this table: there are no major obstacles to map a basic data type from Elisa to C and visa versa. However, the memory layouts of strings, arrays and structures are quite different.


18.3 Strings in C

In the C language a string is an array of characters closed by a null character. In Elisa, text, which is an array of characters, can be converted to a C-string by means of the foreign function:

foreign(c) _Cstring(text) -> CstringPtr;

The _Cstring function converts an Elisa text into a pointer to a Cstring. The CstringPtr is defined by:

type CstringPtr = subtype(integer);

It is also possible to convert a Cstring into an Elisa text by means of the foreign function:

foreign(c) _text(CstringPtr) -> text;

The complete set of string conversion declarations is:

    type CstringPtr = subtype(integer);
    foreign(c) _Cstring(text) -> CstringPtr;
    foreign(c) _text(CstringPtr) -> text;

18.4 Arrays in C

The memory layouts of Elisa arrays and C arrays are incompatible. In some foreign  C functions a reference to a C array is required. This can be done by converting an array written in Elisa to an array processable by C. For example, an array of reals in Elisa can be converted to a pointer to the array of reals as is used in C,  by means of the foreign function:

 foreign(c) _ArrayPtr(array(real)) -> CarrayPtr;

The _ArrayPtr function converts  an Elisa array of reals into a pointer to a Carray. The CarrayPtr is defined by:

type CarrayPtr = subtype(integer);

Array conversion declarations are: 

    foreign(c) _ArrayPtr(array(character)) -> CarrayPtr;
    foreign(c) _ArrayPtr(array(boolean)) -> CarrayPtr;
    foreign(c) _ArrayPtr(array(integer)) -> CarrayPtr;
    foreign(c) _ArrayPtr(array(real)) -> CarrayPtr;

18.5 Examples

The use of foreign C declarations to operate on C files are: 

type CstringPtr = subtype(integer);
foreign(c) _Cstring(text) -> CstringPtr;
foreign(c) _text(CstringPtr) -> text;

type CarrayPtr = subtype(integer);
foreign(c) _ArrayPtr(text) -> CarrayPtr;
type TextFile = subtype(integer);
type StreamFile = subtype(integer);
foreign(c) fopen(FileName = CstringPtr, FileMode = CstringPtr) -> TextFile;
foreign(c) fclose(TextFile) -> integer;
foreign(c) remove(FileName = CstringPtr) -> integer;

foreign(c) fgets(CstringPtr, MaxStringSize = integer, TextFile) -> integer;
foreign(c) strlen(CstringPtr) -> integer;

foreign(c) ObtainErrorFile( ) -> TextFile;
foreign(c) fprintf(outtextfile = TextFile, format = CstringPtr, character) -> nothing;

foreign(c) fseek(StreamFile, FileOffset = integer, Origin = integer) -> integer;
foreign(c) fwrite( CarrayPtr, Size = integer, Number = integer, StreamFile) -> integer;

Top of Page   Part 1: Language Description   Chapter 18: External Interfaces 


Home | Highlights of Elisa | Integrating Different Paradigms | Getting Started with Elisa | Demo's  | What is Domain Orientation | Bibliography | Copyright | News | Contact | Contents

Language Description:

Lexical Elements | Basic Data Types and Expressions | Definitions | Streams | Backtracking | Statements and Special Expressions | Arrays | Lists | Descriptors | Components | Collections | Generic Components | Terms | Categories | Types | Built-in Definitions | Higher-order Definitions | External Interfaces | Index 

Data Structures: Sequences | Examples involving Lists | Trees | Graphs | Searching State Spaces | Language Processing | Knowledge Representations
Domain Modeling:

Domain Modeling | Concepts | Domain Definitions | Domain Operations | Domain Implementations | Systems | Case study: an Order processing system | Case study: an Airport Support system | Domain Orientation versus Object Orientation

Design Patterns:

Introduction | Abstract Factory | Builder | Factory Method | Prototype | Singleton | Adapter | Bridge | Composite | Decorator | Facade | Flyweight | Proxy | Chain of Responsibility | Command | Interpreter | Iterator | Mediator | Memento | Observer | State | Strategy | Template Method | Visitor 


click tracking

This page was last modified on 27-09-2012 13:54:36   

free hit counter