Empty string: Difference between revisions

Content deleted Content added
m Removed 'The' from the beginning of the short description per WP:SDFORMAT. (via WP:JWB)
Use in programming languages: WP:LINKs: updates, fix-cut needless WP:PIPEs (WP:NOPIPEs). Cut needless carriage returns in paragraphs. Small WP:EoS WP:TERSE WP:COPYEDITs.
Line 20:
 
==Use in programming languages==
In most programming languages, strings are a [[data type]]. Strings are typically stored at distinct [[Memory address|memory locationsaddress]]es (locations). Thus, the same string (for example, the empty string) may be stored in two or more places in memory.
This means that the same string (for example, the empty string) could be stored in two or more places in memory.
 
In this way, there could be multiple empty strings in memory, in contrast with the formal theory definition, for which there is only one possible empty string. However, a string comparison function would indicate that all of these empty strings are equal to each other.
However, a string comparison function would indicate that all of these empty strings are equal to each other.
 
Even a string of length zero can require memory to store it, depending on the format being used. In most programming languages, the empty string is distinct from a [[null reference]] (or null pointer) because a null reference does not pointpoints to anyno string at all, not even the empty string.
<!---A null reference is likely to cause an error if one tries to perform any operation on it, but an empty string is less likely to do so.--->
The empty string is a legitimate string, upon which most string operations should work. Some languages treat some or all of the following in similar ways: empty strings, null references, the integer 0, the floating point number 0, the Boolean value [[False (logic)|false]], the [[ASCII]] character [[null character|NUL]], or other such values.
Line 37 ⟶ 35:
|-
| <code>""</code>
| [[C (programming language)|C]], [[C Sharp (programming language)|C#]], [[C++]], [[Go (programming language)|Go]], [[Haskell (programming language)|Haskell]], [[Java (programming language)|Java]], [[JavaScript]], [[Julia (programming language)|Julia]], [[Lua (programming language)|Lua]], [[MUMPS|M]], [[Objective-C]] (as a C string), [[OCaml]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[Scala (programming language)|Scala]], [[Standard ML]], [[Swift (programming language)|Swift]], [[Tcl (programming language)|Tcl]], [[Visual Basic .NET]]
|-
| <code>&#39;&#39;</code>
| [[APL (programming language)|APL]], [[Delphi (programming language)|Delphi]], [[JavaScript]], [[Matlab (programming language)|MatlabMATLAB]], [[Pascal (programming language)|Pascal]], [[Perl]], [[PHP]], [[Python (programming language)|Python]], [[Ruby (programming language)|Ruby]], [[Smalltalk (programming language)|Smalltalk]], [[SQL]]
|-
| <code>{'\0'}</code>