Go to the previous, next section.

# Possible ISL Name Mappings for Target Languages

This note outlines a proposal for name mappings and restrictions; this proposal is not yet accepted. (Thanks to external standards such as CORBA, this proposal cannot be implemented for some languages, such as ANSI C.) The mappings outlined here are not necessarily the ones used in the current ILU release.

This proposal is about how to name things in the various programming languages, in a way that avoids name clashes. It imposes no restrictions on the ISL source. However, the mappings will be more straightforward if the ISL source avoids two things: (1) two or more concsecutive hyphens in a name, and (2) starting an interface or type name with "ilu-" (in any casing).

The first step in mapping an ISL to a programming language is to scan type and interface names for the substring "ilu-" (in any casing); wherever it occurs, we insert a trailing digit zero.

In a similar way, we next scan the name for sequences of hyphens. Wherever two or more hyphens appear consecutively, the digit zero (`0') is inserted after every other one, starting with inserting a zero after the second hyphen.

The following steps assume the first two steps have already been done.

Where tuples <N1, N2, ... Nk> of ISL names must be mapped into a flat programming namespace, we concatenate the ISL names, with a double hyphen ("--") inserted between each.

Where ISL names (or tuples thereof) must be mapped, together with ILU-chosen names derived from the ISL names, into a flat programming namespace, the derived names begin with fixed strings specific to the derivation, where the fixed strings begin with "ilu-" (with any case), and a double hyphen is inserted between the fixed string and the ISL name.

Where ISL names (or tuples thereof), and possibly ILU-chosen names derived from the ISL names, must be mapped, together with a fixed set of ILU-chosen names, into a flat programming namespace, the fixed ILU-chosen names begin with "ilu-" (with any case) and do not include a double hyphen.

The final step is to translate hyphens to underscores, for programming languages that accept underscores but not hyphens in names.

Following is a specification of how names are mapped in each language. The notation "[N]" is used to denote the application of the first two steps and the last step. Examples of "[..]" are:

    [Foo] => Foo
    [foo-bar] => foo-bar
    [wait----for--it-] => wait--0--0for--0-it-
    [iluminate] => iluminate
    [ilu--uli] => ilu-0--0uli

The mappings also use the notation "[[..]]" to denote the mapping of a type-reference.

## C mapping

[ This mapping, while clean, will never be adopted because of the more problematic mapping specified by the OMG's CORBA document. ]

Item `N` from interface `I` is mapped to `[I]__[N]`. `[[I.N]] = [I]__[N]`; `[[N]] = [I]__[N]`, where `I` is the current interface.

An enumerated value named `V`, of type `T` in interface `I` is mapped to `[I]__[T]__[V]`.

A declaration of a record type `T` in interface `I` with fields `F1:TR1`, ... `Fn:TRn` is mapped to

    typedef struct {[[TR1]] F1; ... [[TRn]] Fn} [I]__[T];

A declaration of a union type `T` in interface `I` of types `TR1`, ... `TRn` is mapped to

    typedef enum {[[I.T]]__[[TR1]], ... [[I.T]]__[[TRn]]} ilu_tags__[[I.T]];
    typedef struct {ilu_tags__[[I.T]] tag;
        union {
            [[TR1]] [[TR1]];
            ...
            [[TRn]] [[TRn]];
        } val;
    } [[I.T]];

For passing exceptions through the method calls in interface `I`, the following auxiliary declaration is generated (supposing exceptions `ER1:TR1`, ... `ER2:TR2` are raised):

    typedef struct {
        ilu_Exception returnCode;
        union {
            [[TR1]] [[ER1]];
            ...
            [[TRn]] [[ERn]];
        } val;
    } ilu_Status__[I];

An object type named `T` in interface `I` with methods `M1`, ... `Mn` maps to

    typedef ilu_Ojbect [[I.T]];
    [result-type-1] [I]__[T]__[M1]([[I.T]] ilu_self,
        [[arg-type-1-1]] [arg-name-1-1], ...
        [[arg-type-1-k]] [arg-name-1-k]);
    ...

## C++ mapping

Item `N` from interface `I` is mapped to `[I]__[N]`. `[[I.N]] = [I]__[N]`; `[[N]] = [I]__[N]`, where `I` is the current interface.

A declaration of an enumerated type named `T` in interface `I` containing values `V1`, ... `Vn` is mapped to `typedef enum {[V1], ... [Vn]} [I]__[T]`.

Record and union declarations are mapped as for C. The exception status declaration is as for C.

## Modula-3 mapping

ILU interface `I` is mapped to Modula-3 interface `[I]`; within an interface, item `N` is mapped to item `[N]`. `[[I.N]] = [I].[N]`; `[[N]] = [N]`. For Modula-3, we also use the notation "((a type-reference))", defined by `((N)) = [N]` and `((I.N)) = [I]__[N]`.

A declaration of a record type `T` in interface `I` with fields `F1:TR1`, ... `Fn:TRn` is mapped to

    TYPE [T] =  RECORD F1: [[TR1]]; ... Fn: [[TRn]]; END;

A declaration of a union type `T` in interface `I` of types `TR1`, ... `TRn` is mapped to

    TYPE [T] = BRANDED OBJECT END;
    TYPE [T]__((TR1)) = [T] BRANDED OBJECT v: [[TR1]] END;
    ...
    TYPE [T]__((TRn)) = [T] BRANDED OBJECT v: [[TRn]] END;

A declaration of an enumerated type named `T` in interface `I` containing values `V1`, ... `Vn` is mapped to `TYPE [T] = {[V1], ... [Vn]};`

The type `Ilu.Object` has slots named `ilu_is_surrogate`, `Ilu_Get_Server`, `Ilu_Get_Type`, and `Ilu_Close_Surrogate`. Method names `M` are translated to `[M]`. For each object type `T`, the Modula-3 interface includes auxiliary procedures named `Ilu_Sbh_Import__[T]`, `Ilu_Name_Import__[T]`, and `Ilu_Get_Type__[T]`.

Go to the previous, next section.