Sound programming language

Tool for processing unified data (Sound – system for operating with unified data) is developed for clear programming that ensures that the results of calculations correspond to the intended purposes. The purpose of data refers to the formal specification of the computations leading to that data. The Sound programming language is needed as a universal tool that allows you to translate computational logic into any programming language.

Clear programming implies that the result of evaluating an expression will remain within the scope of the evaluation result type and conform to the formal specification. Thus, a clear programming language should provide tools for direct or indirect specification input along with control of the correctness of the data.

The purpose of data is its logical content, expressed as a logical formula denoting the meaning of the data. The Sound language allows you to indirectly express the logical relationships between the destinations of the results of intermediate calculations. While the specification is usually introduced in program comments and is not expressed in the programming language, language constructs should facilitate understanding of the internal logic of the calculations so that the reader can, if possible, verify that this logic corresponds to the required result.

For example, the procedure for converting a number into an array of digits consists of a looping block that takes a number as input and returns its lowest digit, which is then stored in the next element of the sequence. In Sound language this is expressed as follows:

from Compute where {DigitsRange=range(0), Sequence=Array<DigitsRange>, Number=Int} call NumberToDigits(100, 2)

module Compute:
    type Sequence, DigitsRange, Number
    
    func NumberToDigits (x: Number, base: Number) -> a: Sequence[DigitsRange] =
    {
        if x < 0:
            Error.NegativeNumber(x)
        k: DigitsRange = 0  # количество цифр
        y = x  # тип назначается автоматически
        for:
            next_digit(@y, base, @a, k) -> ok: Bool =
            {
                digit = lowest_digit (y, base) -> d: Number = 
                {
                    d = y % base    
                }
                @a[k] = digit
                @y /= base
                ok = (y != 0)
            }
            if ok:
                k += 1
            else:
                stop
        if k == 0:
            k = 1
            a[0] = 0
    }

An important point in programming languages ​​are names denoting certain concepts. There are three types of names in the Sound language: 1) names that directly designate data of one type or another; 2) names denoting specific data types; 3) names denoting abstract data types.

In Sound, an abstract data type is a name that can be replaced by the name of any concrete data type for which the calculation logic does not prohibit this.

An example of an abstract data type is an indexable container. Indexing is done using the “range” type. In the case of a fixed number of indexes, they are listed separated by commas and placed in square brackets; in the case of a variable number of indexes, the “multidimensional range” type is introduced, which is placed in double square brackets. The range can be a type of container-specific index numbers. This means that a language might prohibit indexing, say, a number sequence and a string sequence using the same range, because the meaning of the indexes may be different. This can be convenient in cases where you have to work with many data at once, and each index variable indicates access to data of a certain type.

Unifying the purpose of data means that with each name denoting data, the semantics of the stored data is defined. In the example of converting a number into a sequence of digits, this semantics is expressed in a named block.

However, I would like to be able to express in language the logical relationships between the computational blocks, so that when reading the program, I can decide whether the computational logic corresponds to its intended purpose. The Unified Data Purpose Language includes the following elements:

· external interfaces – data models

· internal interfaces – data structures

· destinations – data semantics

In the example considered, the data destination is the repetition of a block with a transition from state number k in state with number k+1.

Sound technology can be implemented within any programming language, so the Sound language can be translated into any language. According to the stored program principle, every program is data that can be processed by a translator. Therefore, in the number digits example, the array is not initially declared, and the details related to memory allocation can be described outside the compute module.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *