What is the principle of completeness type?

The book Concepts of Designing a Programming Language says:

PYTHON counts procedures as first-class values ​​along with all primitive and compound values. Thus, PYTHON is in good agreement with the principle of completeness .

I still do not understand.

+6
source share
1 answer

The principle of completeness type:

No operation should be arbitrarily limited to the types of values ​​involved. - watt

First-class values ​​can be evaluated, passed as arguments, and used as composite values ​​of compound values. Functional languages ​​try to make no distinction in a class, while imperative languages ​​usually treat functions (if better) as values ​​of the second class.

Almost all programming languages ​​limit the types of objects that can pass as values ​​(and, therefore, have a significant type). In C or C ++, functions are not values, although pointers to functions. Classes are not values.

In Java, methods and classes are not values, although you can get a reified object representing the class as a value, and in Java 8, you can pass method references as values. Packages are not important.

In Haskell, functions are first-class values, so they can be passed as arguments and returned as values. Because Haskell is statically typed, the type system is able to express function types.

+7
source

Source: https://habr.com/ru/post/1012710/


All Articles