Null function

Null function

In computer science, a null function (or null operator) is subroutine that returns no data values and leaves the program state unchanged. When it is part of the instruction set of a processor, it is called a NOP or NOOP (No OPeration).

Mathematically, a (computer) function f is null if and only if its execution leaves the program state s unchanged. That is, a null function is an identity function whose domain and codomain are both the state space S of the program, and for which:

f(s) = s for all elements s in S.

Less rigorous definitions may also be encountered. For example, a function may take a single operand, transform it into a new data type, and return the result.[1] While such usages bear a strong visual resemblance to identity functions, they create or alter a binary data value and thus change the program state. From a software maintainability perspective it is better to identify such "minor" alternations of state explicitly, since calling them null functions provides future maintainers of the code with no insights on their actual purposes.

Uses

Null functions have several uses.

During software development, null functions with the same names and type signatures as a planned functions are often used as stubs—that is, as non-functional placeholders that allow the incomplete body of code to be compiled and tested prior to completion of all planned features.

Null functions, particularly the NOP variety, are also used to provide delays of indeterminate length within wait loops. This is a common strategy in dedicated device controllers that must wait for an external input and have no other tasks to perform while they are waiting. Such wait loops are also used in software applications on larger multiprocessing computer systems. However, for multiprocessing systems a better approach is to use operating system functions that let other processes use the CPU during the waiting period.

A third use of null functions is as the definition of a program feature that, if created inadvertently, is almost always deleterious. Unintended null functions can arise during the development of complex programs, and like dead code, such occurrences indicate serious flaws in program structures.

A null function or method is often used as the default behavior of a revectorable function or overrideable method in an object framework.

Notes

  1. ^ Example of a type conversion function labeled as a "null function": _NULLF - null function.

Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Null Object pattern — Null object redirects here. For the concept in category theory, see Initial object. In object oriented computer programming, a Null Object is an object with defined neutral ( null ) behavior. The Null Object design pattern describes the uses of… …   Wikipedia

  • Null (SQL) — The Greek lowercase omega (ω) character is used to represent Null in database theory. Null is a special marker used in Structured Query Language (SQL) to indicate that a data value does not exist in the database. Introduced by the creator of the… …   Wikipedia

  • Null character — For other uses, see Null symbol. The null character (also null terminator), abbreviated NUL, is a control character with the value zero.[1] [2] It is present in many character sets, including ISO/IEC 646 (or ASCII), the C0 control code, the… …   Wikipedia

  • Null (computer programming) — Null has several meanings in computer programming.;Null pointer or null reference * Null is a special pointer value (or other kind of object reference) used to signify that a pointer intentionally does not point to (or refer to) an object. Such a …   Wikipedia

  • Null-steering beamformer — Null Steering is a method of beam forming for narrow band signals where we want to have a simple way of compensating delays of receiving signals from a specific source at different elements of the antenna array. In general to make use of the… …   Wikipedia

  • Null set — In mathematics, a null set is a set that is negligible in some sense. For different applications, the meaning of negligible varies. In measure theory, any set of measure 0 is called a null set (or simply a measure zero set). More generally,… …   Wikipedia

  • Null cipher — A null cipher is an ancient form of encryption where the plaintext is mixed with a large amount of non cipher material. It would today be regarded as a simple form of steganography. Null ciphers can also be used to hide ciphertext, as part of a… …   Wikipedia

  • Null coalescing operator — The null coalescing operator (or Logical Defined Or Operator) is a binary operator that is part of the syntax for a basic conditional expression in several programming languages, including C#,[1] and Perl as of version 5.10.[2] In Scheme, boolean …   Wikipedia

  • Null hypothesis — For the periodical, see Null Hypothesis: The Journal of Unlikely Science. The practice of science involves formulating and testing hypotheses, assertions that are capable of being proven false using a test of observed data. The null hypothesis… …   Wikipedia

  • Null allele — A null allele is a mutant copy of a gene that completely lacks that gene s normal function. This can be the result of the complete absence of the gene product (protein, RNA) at the molecular level, or the expression of a non functional gene… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”