Dynamic typing
All the computer programming languages allow, directly or indirectly, to handle Valeur S. Généralement, it is via Variable S, which are an association (one says also a connection) between a Symbole and a value.
For example, in language C++, the extract of following program:
… int has; has = 5; …
declare a variable indicated “has”, of whole type, and affects value 5 to it. C++ is a language with static Typage.
In Common Lisp, one will write:
(let ((has 5)) …)
Here, the creation of a lexical variable is done without specifying the type. It is the characteristic of a language with dynamic typing: the type of the data is not associated with the symbol which indicates the variable but is encodé in the data itself. Thus, in the range of the “let”, one can question the type of the variable has (it is an application of the Réflexivité):
(let ((has 5)) (when (numberp a) (print " has is a nombre")) …)
Moreover, in the course of execution, “has” could receive an object of the different type, if the program authorizes it:
(let ((has 5) (setf has " I am a chaîne") …)
In short, dynamic typing is a very convenient solution for the fast development of programs, where the type of the handled objects is not inevitably known in advance. It is necessary to the development of a Protocol for Méta-Objects, or MOP, because static typing the interdict.
Implications of dynamic typing
The great flexibility which allows dynamic typing generally pays by an overconsumption of memory corresponding to the encoding of the type in the value, like by a loss of performance due to the additional indirections. This overcost with the execution however is counterbalanced by the increase in the power of the current computers, and allows the Fast development of applications.
For the expensive algorithmic operations, the languages of script like Python, Tcl or Ruby can be interfaced with libraries written in low-level language like the language C. Moreover, certain languages (in particular Common Lisp) allow an optional static declaration of the type, in order to prove the consistency of typing to compilation and to remove the indirections.
When a function receives a data of an incorrect type (error of the type to the execution), a exception is raised.
Examples
See too
| Random links: | Battle of Argentoratum | Relámpago de la bola | Bohemian Club | Sébazac-Concourès | Suphanburi FC | Baritone (voice) |