Content deleted Content added
Aadirulez8 (talk | contribs) m v2.05 - Fix errors for CW project (Reference list missing / disambiguation page with disallowed <ref>) |
|||
(40 intermediate revisions by 27 users not shown) | |||
Line 1:
{{ProgLangCompare}}
Line 8 ⟶ 7:
===Common variants===
{| class="wikitable"
|-
Line 15 ⟶ 13:
|-
| +
| [[ALGOL 68]], [[
|-
| ++
| [[
|-
| $+
| [[
|-
| &
| [[Ada (programming language)|Ada]], [[AppleScript]], [[COBOL]] (for literals only), [[Curl (programming language)|Curl]], [[
|-
| concatenate
| [[Common Lisp]]
|-
| .
| Autohotkey, [[
|-
| ~
| [[
|-
| <nowiki>||</nowiki>
| [[Icon (programming language)|Icon]],
|-
| <>
| [[Mathematica]], [[Wolfram Language]], [[Elixir (programming language)|Elixir]]
|-
| ..
| [[Lua (programming language)|Lua]]
|-
| :
| [[Pick Basic]]
|-
| ,
| [[
|-
| ^
| [[
|-
| //
| [[Fortran]]
|-
| *
| [[Julia (programming language)|Julia]]
|}
===Unique variants===
* [[
* [[C (programming language)|C]] (along with [[Python (programming language)|Python]] and [[Dart (programming language)|Dart]]<ref>{{Cite web |title=Built-in types |url=https://dart.dev/language/built-in-types/ |access-date=2025-07-22 |website=dart.dev |language=en}}</ref>) allows juxtaposition for string literals, however, for strings stored as [[Character (computing)|character]] [[Array data structure|arrays]], the <code>[[strcat]]</code> function must be used.
* [[COBOL]] uses the <code>STRING</code> statement to concatenate string variables.
* [[MATLAB]] and [[GNU Octave
* [[Visual Basic]]
* [[Microsoft Excel]] allows both "<code>&</code>" and the function "<code>=CONCATENATE(X,Y)</code>".
* [[Rust (programming language)|Rust]] has the <code>concat!</code> macro and the <code>format!</code> macro, of which the latter is the most prevalent throughout the documentation and examples.
== String literals ==
Line 70 ⟶ 72:
=== Quoted interpolated ===
An expression is "interpolated" into a string when the compiler/interpreter evaluates it and inserts the result in its place.
<!-- Before you add your favorite language to this table, make sure it's not listed in another section. -->
{| class="wikitable"
Line 77 ⟶ 79:
! Language(s)
|-
| <
| C#, Visual Basic .NET
|-
| <
|
|-
| <
| Perl (alternate)
|-
| <
| PHP (alternate)
|-
| <
| CoffeeScript, Ruby, [[Elixir (programming language)|Elixir]]
|-
| <
| Ruby (alternate)
|-
| <
|[[Common Lisp]]
|-
| <
| JavaScript (ECMAScript 6)
|-
| <
| Swift
|-
| <code>f'Hello, {name}!'</code>
| Python
|}
=== 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.
Line 112 ⟶ 118:
! Language(s)
|-
| <
| C, C++, C#, D, Dart, F#, Java, JavaScript, Mathematica, Ocaml, Perl, PHP, Python, Rust, Swift, Wolfram Language, Ya
|-
| {{nowrap|<
| CoffeeScript, Dart (alternate), JavaScript (alternate), Python (alternate)
|-
| <
| Windows Powershell
|-
| <
| REBOL
|-
| <
| REBOL (alternate)
|-
| <
| Eiffel
|-
| <
| FreeBASIC
|-
| {{nowrap|<code>r#"I said "Hello, world!""#</code>}}
|Rust (alternate)
|-
| {{nowrap|<code>R"("I said "Hello, world!")"</code>}}
|C++ (alternate)
|}
Line 142 ⟶ 154:
! Language(s)
|-
| <
| Ada, ALGOL 68, COBOL, Excel, Fortran, FreeBASIC, Visual Basic
|-
| <
|
|}
Line 157 ⟶ 169:
! Language(s)
|-
| <
| APL, Bourne shell, Fortran, Object Pascal, Pascal, Perl, PHP, Pick Basic, Ruby, Smalltalk, Windows PowerShell
|-
| <code>q(Hello, world!)</code>
| Perl (alternate)
|-
| <code>%q(Hello, world!)</code>
| Ruby (alternate)
|-
| <code>R"(Hello, world!)"</code>
| C++11
|-
| <code>@"Hello, world!"</code>
| C#, F#
|-
| <
|
|-
| <
| Dart (alternate)
|-
| <
| Cobol, FreeBASIC, Pick Basic
|-
| <
| D, Go
|-
| <
|
|-
| <code>String.raw`Hello, World!`</code>
| JavaScript (ECMAScript 6) {{ref|es6rawstr}}
|}
Line 182 ⟶ 209:
|-
! Syntax
! Here
! Language(s)
|-
| <pre><<EOF
I have a lot of things to say
and so little time to say them
EOF</pre>
| {{Yes}}
| Bourne shell, Perl, Ruby
|-
| <
I have a lot of things to say and so little time to say them EOF</ | {{Yes}}
| PHP
|-
| <pre>@"
I have a lot of things to say
and so little time to say them
"@</pre>
| {{No}}
| Windows Powershell
|-
| <pre>"[
I have a lot of things to say
and so little time to say them
]"</pre>
| {{No}}
| Eiffel
|-
| <pre>"""
I have a lot of things to say
and so little time to say them
"""</pre>
| {{No}}
| CoffeeScript, Dart, Groovy, Kotlin, Python, Swift
|-
|<pre>"
I have a lot of things to say
and so little time to say them
"</pre>
| {{No}}
|[[Common Lisp]] (all strings are multiline), Rust (all strings are multiline), Visual Basic .NET (all strings are multiline)
|-
| <pre>R"(
I have a lot of things to say
and so little time to say them
)"
</pre>
| {{No}}
| C++
|-
| <pre>r"
I have a lot of things to say
and so little time to say them
"</pre>
| {{No}}
| Rust
|-
| <pre>[[
I have a lot of things to say
and so little time to say them
]]</pre>
| {{No}}
| Lua
|-
| <pre>`
I have a lot of things to say
and so little time to say them
`</pre>
| {{No}}
| JavaScript (ECMAScript 6)
|}
Line 214 ⟶ 292:
! Language(s)
|-
| <
| Hollerith notation
| Fortran 66
Line 222 ⟶ 300:
| YAML
|}
== Notes ==
:1. {{note|es6rawstr}} <code>String.raw``</code> still processes string interpolation.
==References==
{{Reflist}}
:1. {{note|es6rawstr}} https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw
[[Category:Programming language comparisons|*Strings]]
|