Skip to content
ggeorgiev edited this page Jun 17, 2012 · 9 revisions

Language

Overview

Compil as a project, and in particular the compil language itself, does not favor any specific programming language. Its design aims at generating as easy to read source code as possible - without introducing big number of operators and special sintaxes in the constructions, but also without necessarily avoiding them. The terminology is based on what makes sense and similarities with one language or another are not purposly avoided.

Type system

Compil has a very flexible type system. Based on a number of simple types and abilities for custom defined types, it provides virtually unlimited type capabilities. Note we are distinguishing between simple and built-in types. Compil offers complex built-in types too.

Simple types

Compil type system has a very small number of simple types and all of them are built-in. These are the least common denominator between all the supported languages. Compil has built-in types for boolean, signed integer numbers and real numbers.

  • boolean
  • small - [-128, 127]
  • short - [-32768, 32767]
  • integer - [−2147483648, 2147483647]
  • long - [−9223372036854775808, 9223372036854775807]
  • real32
  • real64

Semi-simple types

Compil also provides a collection of semi-simple types. They though could be either not supported from all programming languages themselves or supported by more than one technology in a particular language. In both cases these types have special treatment based on language and configuration. However they are still considerably simple types by nature.

Memory block holders

  • string
  • binary

Integer range

Not all languages support unsigned integers. You may say this is not a significant limitation since language as Java could have it. Unfortunately the level of inconvenience this creates in languages with unsigned integers support such as C++ is significant - especially when the generated from compil code is in active interaction with libraries implemented with unsigned integer as STL for example.

To overcome this problem compil provides integer range type. This type specifies the range of the numbers that are going to be stored. Then the compil generation engine, based of configuration, picks the best available type for the particular language.

Compil provides several built-in integer ranges:

  • size - [0, 9223372036854775807]
  • byte - [0, 255]
  • word - [0, 65535]
  • dword - [0, 4294967295]
  • qword - [0, 18446744073709551615]

Castable types

Compil divides all types in two categories based on whether they represent a weak or strong castable type.

Weak types

A weak type is a type that provides a weak castable defense. In other words such types could be easily cast to a similar type without compile time validation.

Strong types

A strong type is a type that provides a strong castable defense. It will be hard to assign another type to it by mistake.

Enumeration

Enumeration is a type that can be used to set up collections of named integer constants. It could be defined as a weak or a strong type - see castable type. Note, that compil may or may not use the default for the language enumeration abilities.

enum Weakdays
{
    Sunday;
    Monday;
    Tuesday;
    Wednesday;
    Thursday;
    Friday;
    Saturday;
}

Compil does not use the default for any compiler auto numbering system. It will generate code that ensures that all the names will have incremental numbers one based. The zero is reserved for invalid value initialization. In this example we will have Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4, Thursday = 5, Friday = 6, Saturday = 7.

Flags enumeration or named bitset

When enumeration is specified as flags this changes the enumeration where every name represents a bit instead of arbitrary unique number.

flags enum Weakdays
{
    Sunday;
    Monday;
    Tuesday;
    Wednesday;
    Thursday;
    Friday;
    Saturday;
}

In this case we will have Sunday = 1, Monday = 2, Tuesday = 4, Wednesday = 8, Thursday = 16, Friday = 32, Saturday = 64. It will also create for convenience values nil = 0 and all = 127. Note that for flags enum type you could combine several names in a single value:

flags enum Weakdays
{
    ...
    Workday = Monday | Tuesday | Wednesday | Thursday | Friday;
    Weekend = Sunday | Saturday;
}

Flags enumeration provides additional methods to operate with it.

Method reset(mask, value)

Resets the flags included in the mask to the state in value

Method set(mask)

Sets the flags included in the mask. Equivalent to reset(mask, all).

Method clear(mask)

Clears the flags included in the mask. Equivalent to reset(mask, nil).

Method flip(mask)

Flips the flags included in the mask.

Method test(mask, value)

Tests if the flags included in the mask are the same state as state in value

Method isSet(mask)

Tests if the flags included in the mask are set. Equivalent to test(mask, all).

Method isClear(mask)

Tests if the flags included in the mask are clear. Equivalent to test(mask, nil).

Time

  • time.date
  • time.time
  • time.datetime
  • time.duration

Categorical types

  • identifier
  • index

Containers

Compil has for a goal to create a data model that is not only useful to store and serialize the data, but also to be convenient for the data to be manipulated. This means that compil needs to offer as appropriate container as possible in every situation. You may not believe it but there are hundreds of different containers offered by tens of libraries per every programming language. And there is something in common between all of these and it is that no one agrees completely with any of the others.

Compil container specification is based on characteristics. This way based on configuration and language compil will choose the best available container for the specified characteristics.

Type Parameters

The containers could be unary or binary

Sizable

The containers could be fixed or dynamic according to the number of items they hold.

Order

The containers could be fixed sequence, sorted or unordered.