# Predeclared

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Predeclared
> Markdown URL: https://mediated.wiki/source/Predeclared.md
> Source: https://en.wikipedia.org/wiki/Predeclared
> Source revision: 1321092297
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{More citations needed|date=November 2025}}{{Short description|Programming construct}}
In computer languages, the built-in information, encodings or tools that are available to a [programmer](/source/Computer_programmer) are '''pre-declared''', often in the form of entities, variables, objects, functions or instructions. It is mostly not possible to overwrite or otherwise manipulate them.

== Pre-declared entity ==

A pre-declared entity is a built-in notation convention for a [character](/source/Character_(mathematics)) or a [string](/source/String_(computer_science)). For example, in the [HTML](/source/HTML) markup language, a large number of character and numeric entities are available to represent characters. In HTML, '&amp;lt;' is a possible pre-declared entity to represent '<'.<ref>{{cite web |title=HTML Character Entities |url=https://www.w3schools.com/html/html_entities.asp |website=w3schools.com |access-date=November 8, 2025}}</ref> The programmer must not declare this entity by himself before he can use it, since it is already pre-declared by the specifications of the [HTML](/source/HTML) language. Pre-declared entities are often used as [escape sequence](/source/escape_sequence)s to represent information that would otherwise cause possible conflicts in its non-encoded form.

== Pre-declared variable ==

When a variable is pre-declared, it provides the programmer with information that he might be interested in. For example, in the [Perl](/source/Perl) language, a [variable](/source/Variable_(programming)) %ENV is pre-declared, holding environmental information such as the [operating system](/source/operating_system), host information, user information, and much more.<ref>{{cite web |title=%ENV |url=https://perldoc.perl.org/variables/%25ENV |website=perl.org |access-date=November 8, 2025}}</ref> Other pre-declared variables in Perl are %INC and %SIG. Almost all common programming languages provide the programmer with such pre-declared variables in one or another form.

When variables are pre-declared, it is commonly assumed that the value for the pre-declared name is also pre-assigned at the same time.

== Pre-declared object==

Pre-declared [object](/source/object_(computer_science))s have the same goal as pre-declared variables. For example, in the [JavaScript](/source/JavaScript) language, the navigator-object is available to get all kinds of information about the [browser](/source/web_browser) that is running the script in question.

== Pre-declared functions and instructions ==

Pre-declared [functions](/source/Subroutine) or [instructions](/source/Instruction_(computer_science)) are built-in tools to perform common tasks. For example, in the earliest [programming language](/source/programming_language)s the [square root](/source/square_root) needed to be calculated by hand. Nowadays programming languages have a pre-declared instruction or function for this task. Pre-declared functions or instructions often hold common tasks and their goal is to simplify the work of the programmer. The available pre-declared instructions or functions can in some languages be extended by using external libraries or [modules](/source/Modularity_(programming)).

== Narrow semantic sense ==

In a narrow strictly [semantic](/source/semantic) sense, the term pre-declared may also refer to the [declaration](/source/Declaration_(computer_programming)) of a [variable](/source/Variable_(programming)) before an assignment takes place. In the following example, the first line is the (pre-)declaration and the second the [assignment](/source/assignment_(computer_science)):

    '''var''' A;
    '''A''' = 1;

By declaring the name A, the program creates a [namespace](/source/namespace) for the variable called A. In most modern languages, the variable does not need to be pre-declared on a separate line, as the following instruction achieves exactly the same:

    '''var''' A = 1;

In early computer languages, the variable always needed to be pre-declared as a separate instruction, because the [operating system](/source/operating_system) had to reserve a series of [byte](/source/byte)s in the available [RAM](/source/RAM), before the actual value of the variable could be stored in it. [Declaration](/source/Declaration_(computer_science)) and [assignment](/source/Assignment_(computer_science)) are still two fundamental different things, though they nowadays mostly appear in a same instruction line.

==References==
{{Reflist}}

Category:Programming constructs
Category:Computer programming

---
Adapted from the Wikipedia article [Predeclared](https://en.wikipedia.org/wiki/Predeclared) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Predeclared?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
