Empty string

Empty string

In computer science and formal language theory, the empty string (or null string)[1] is the unique string of length zero. It is denoted with λ or sometimes Λ or ε.

The empty string is distinct from a null reference in that in an object-oriented programming language a null reference to a string type doesn't point to a string object and will cause an error were one to try to perform any operation on it. The empty string is still a string upon which string operations may be attempted. Some languages however, may treat empty and null strings the same, e.g. if they use COM's strings.

A related concept is the empty language ∅, a formal language that contains no strings.

Contents

Properties

When present in a formal language, empty strings have several properties:

These properties may hold in some programming languages, but this is left up[citation needed] to the particular implementation.

Representations

The empty string usually represented in a way not different from a generic string. In implementations with string terminating character (C strings or plain text lines) it is just this terminating character placed to the first position.

λ representation Programming languages
"" C, C++, Perl, Python, C#, Go, PHP, Visual Basic .NET, Java, Turing, JavaScript, Haskell, Objective Caml, Tcl
'' Perl, PHP, Python, JavaScript, Delphi, Pascal
{'\0'} C, C++
std::string() C++
@"" Objective-C
qw() Perl
""""""
str()
Python
string.Empty C#
String.Empty Visual Basic .NET
String.make 0 '-' Objective Caml
{} Tcl

Occurrence

The empty string is a syntactically valid representation of zero in positional notation (in any base), which does not contain leading zeros. Because handling of empty strings is problematical (particularly in a graphic environment), the zero number traditionally represented by one decimal digit 0 instead.

Zero-filled memory area, interpreted as a C string, is an empty string.

Empty lines (say, two consecutive EOLs) often occurred in text files and sometimes used in text processing to separate paragraphs, e.g. in MediaWiki.

See also

References

  1. ^ Kernighan and Ritchie, C, p. 38
  2. ^ CSE1002 Lecture Notes - Lexicographic



Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • String (computer science) — In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet. In computer programming, a string is traditionally a sequence of… …   Wikipedia

  • String operations — In computer science, in the area of formal language theory, frequent use is made of a variety of string functions; however, the notation used is different from that used on computer programming, and some commonly used functions in the theoretical …   Wikipedia

  • Comparison of programming languages (string functions) — String functions redirects here. For string functions in formal language theory, see String operations. Programming language comparisons General comparison Basic syntax Basic instructions Arrays …   Wikipedia

  • Empty Walls — Single infobox Name = Empty Walls Artist = Serj Tankian from Album = Elect the Dead Released = September 10 2007 (Internet) October 15 [ [http://www.manchestereveningnews.co.uk/entertainment/music/single reviews/s/1020596 serj tankian empty walls …   Wikipedia

  • empty — 1. adjective /ɛmptiː/ a) devoid of content b) Containing no elements (as of a string or array), opposed to being null (having no valid value). Syn: clean …   Wiktionary

  • Empty [null] string — Пустая строка …   Краткий толковый словарь по полиграфии

  • Magic string — A magic string is an input that a programmer believes will never come externally and which activates otherwise hidden functionality. A user of this program would likely provide input that gives an expected response in most situations. However, if …   Wikipedia

  • Six-String Samurai — film poster Directed by Lance Mungia Produced by …   Wikipedia

  • The Incredible String Band (альбом) — The Incredible String Band студийный альбом The Incredible String Band Дата выпуска июнь 1966 Записан …   Википедия

  • The Incredible String Band (album) — Infobox Album | Name = The Incredible String Band Type = Studio album Artist = The Incredible String Band Caption = The original UK cover of the album, showing Clive Palmer, Robin Williamson, and Mike Heron Released = June 1966 Recorded = May… …   Wikipedia

Share the article and excerpts

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