Косвенность
Данная статья нуждается в дополнительных ссылках для подтверждения информации. (февраль 2022 г.) |
In информатике, an адресация is a way of referring to something using a name, ссылки, or container instead of the value itself. [clarification needed]The most common form of indirection is the act of manipulating a value through its адрес в памяти; e.g., accessing a переменной through the use of a pointer. A stored pointer that exists to provide a reference to an object by double indirection is called an узлом косвенной адресации. In some older computer architectures, indirect words supported a variety of more-or-less complicated режимов адресации.
Еще один важный пример — система доменных имен, которая позволяет использовать такие имена, как, en.wikipedia.orgвместо сетевых адресов, например 208.80.154.224. Переход от удобочитаемых имен к сетевым адресам означает, что ссылки на веб-страницу становятся более запоминающимися, и ссылки не нужно изменять при перемещении веб-сайта на другой сервер.
Обзор
A famous афоризм of Лампсона, that is attributed to Дэвиду Уилеру, goes: "All problems in computer science can be solved by another level of indirection" (the "фундаментальная теорема программной инженерии").[1] This is often deliberately mis-quoted[by whom?] with "уровень" substituted for "level of indirection". A Следствием to this aphorism, and the original conclusion from Wheeler, is "...except for the problem of too many layers of indirection."
A юмористической интернет-статье, RFC 1925, insists that:
(6) Переместить проблему (например, переместить проблему в другую часть общей сетевой архитектуры ) проще, чем решить её.
- (6a) (следствие). Всегда можно добавить еще один уровень косвенности.
объектно-ориентированном программировании makes use of indirection extensively, a simple example being динамическая диспетчеризация. Higher-level examples of indirection are the шаблоны проектирования of the В and the прокси-сервер. Делегирование is another classic example of an indirection pattern. In строго типизированных интерпретируемых языках with dynamic типами данных, most variable references require a level of indirection: first the type of the variable is checked for safety, and then the pointer to the actual value is dereferenced and acted on.
В языках со статически заданными размерами для определения рекурсивных типов данных часто используется косвенное обращение . Например, в Rust рекурсивные варианты перечислений требуют, чтобы содержали указательный тип, например Box<T>, , Rc<T>а не напрямую другое значение того же типа. Это дает рекурсивному типу известный размер, поскольку вариант хранит указатель фиксированного размера, в то время как рекурсивное значение хранится в другом месте. [2]
When doing symbolic programming from a formal mathematical specification the use of indirection can be quite helpful. To start with a simple example the variables x, y and z in an equation such as {\textstyle z={\sqrt {x^{2}+y^{2}}}} can refer to any number. One could imagine objects for various numbers and then x, y and z could point to the specific numbers being used for a particular problem. The simple example has its limitation as there are infinitely many real numbers. In various other parts of symbolic programming there are only so many symbols. So to move on to a more significant example, in logic the formula α can refer to any formula, so it could be β, γ, δ, ... or η→π, ς ∨ σ, ... When обозначения построения множеств утверждение Δ={ is employed the statement Δ={α} means the set of all formulae — so although the reference is to α there are two levels of indirection here, the first to the set of all α and then the second to a specific formula for each occurrence of α in the set Δ.
См. также
Ссылки
- ↑ Spinellis, Diomidis (2007). "Another level of indirection". In Oram, Andy; Wilson, Greg (eds.). «Прекрасный код: ведущие программисты объясняют, как они думают. Sebastopol, California: O'Reilly and Associates. pp. 279–291.
- ↑ Klabnik, Steve; Nichols, Carol. "Using Box<T> to Point to Data on the Heap". Язык программирования Rust. No Starch Press. Retrieved 19 июня 2026.
Источники
- Участники английской Википедии. «Indirection». Перевод на русский. CC BY-SA 4.0 (текст и перевод).
Источники иллюстраций
- Question book-new.svg · Лицензия файла уточняется (icon)
- Octicons-terminal.svg · Лицензия файла уточняется (icon)
