Content deleted Content added
m Bot: link syntax and minor changes |
→String literals: Fix a couple incorrect entries, add warning comments, rename "heredoc" section to "multiline string" |
||
Line 71:
=== Quoted raw ===
"Raw" meaning that the interpreter/compiler does not recognize any variable or constant identifiers located inside the string and the content of the identifier will not replace the identifier in the string.
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
|-
Line 86 ⟶ 87:
|-
| <tt>'Hello, world!'</tt>
|
|-
| <tt>`Hello, world!`</tt>
Line 97 ⟶ 98:
=== Quoted interpolated ===
"Interpolated" means that the interpreter/compiler does recognize a variable or constant identifier located inside the string and the content of the identifier will replace the identifier in the string.
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
|-
Line 121 ⟶ 123:
|-
| <tt>"Hello, \(name)!"</tt>
| Swift
|}
=== Escaped quotes ===
"Escaped" quotes means that a 'flag' symbol is used to warn that the character after the flag is used in the string rather than ending the string.
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
|-
Line 132 ⟶ 135:
|-
| <tt>"I said \"Hello, world!\""</tt>
| C, C++, C#, D, F#, Java, Ocaml, Perl, PHP, Python
|-
| <tt><nowiki>'I said
| CoffeeScript, JavaScript (alternate), Python (alternate)
|-
| <tt>"I said `"Hello, world!`""</tt>
Line 152 ⟶ 155:
=== Dual quoting ===
"Dual quoting" means that whenever a quote is used in a string, it is used twice, and one of them is discarded and the single quote is then used within the string.
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
|-
Line 161 ⟶ 165:
|-
| <tt><nowiki>'I said ''Hello, world!'''</nowiki></tt>
| Fortran, rc, COBOL, SQL, Pascal, Object Pascal, APL, Smalltalk
|}
Line 171 ⟶ 172:
=== Multiple quoting ===
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
|-
Line 188 ⟶ 190:
|}
===
Many languages have a syntax specifically intended for strings with multiple lines. In some of these languages, this syntax is a [[here document]] or "heredoc": A token representing the string is put in the middle of a line of code, but the code continues after the starting token and the string's content doesn't appear until the next line. In other languages, the string's content starts immediately after the starting token and the code continues after the string literal's terminator.
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable" border="1"
|-
! Syntax
! Here document
! Language(s)
|-
| <tt><<EOF<br />I have a lot of things to say<br />and so little time to say them<br />EOF</tt>
| Yes
| [[Bourne shell]], Perl, PHP, Ruby
|-
| <tt><<<EOF<br />I have a lot of things to say<br />and so little time to say them<br />EOF</tt>
| Yes
| PHP
|-
| <tt>@"<br />I have a lot of things to say<br />and so little time to say them<br />"@</tt>
| No
| Windows Powershell
|-
| <tt>"[<br />I have a lot of things to say<br />and so little time to say them<br />]"</tt>
| No
| Eiffel
|-
| <tt>"""<br />I have a lot of things to say<br />and so little time to say them<br />"""</tt>
| No
| CoffeeScript, Python, Groovy, Swift
|}
=== Unique quoting variants ===
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
|-
Line 217 ⟶ 227:
! Variant name
! Language(s)
|-
| <tt>13HHello, world!</tt>
|