Backtick

The backtick ` is a typographical mark used mainly in computing. It is also known as backquote, grave, or grave accent.

`
Backtick
In UnicodeU+0060 ` GRAVE ACCENT (symbol)
Related
See alsoU+0300 ̀ COMBINING GRAVE ACCENT (diacritic)

The character was designed for typewriters to add a grave accent to a (lower-case[lower-alpha 1]) base letter, by overtyping it atop that letter.[1] On early computer systems, however, this physical dead key+overtype function was rarely supported, being functionally replaced by precomposed characters.[lower-alpha 2] Consequently, this ASCII symbol was rarely (if ever) used in computer systems for its original aim and became repurposed for many unrelated uses in computer programming.

The sign is located on the left-top of a US or UK layout keyboard, next to the 1 key.[lower-alpha 3] On older keyboards, the Escape key was at this location, and the backtick key was somewhere on the right side of the layout. Provision (if any) of the backtick on other keyboards varies by national keyboard layout and keyboard mapping.


History

Typewriters

Typewriter with French (AZERTY) keyboard: à, è, é, ç ù have dedicated keys; the circumflex and diaeresis accents have dead keys.
Spanish typewriter (QWERTY keyboard) with dead keys for acute, circumflex, diaeresis and grave accents.

On typewriters designed for languages that routinely use diacritics (accent marks), there are two possible solutions. Keys can be dedicated to pre-composed characters or alternatively a dead key mechanism can be provided. With the latter, a mark is made when a dead key is typed but, unlike normal keys, the paper carriage does not move on and thus, the next letter to be typed is printed under the accent.

Incorporation into ISO 646 and ASCII

The incorporation of the grave symbol into ASCII is a consequence of this prior existence on typewriters. This symbol did not exist independently as a type or hot-lead printing character.

It appears to have been at their May 13–15, 1963 meeting that the CCITT decided that the proposed ISO 7-bit code standard would be suitable for their needs if a lower case alphabet and five diacritical marks, including the grave accent, were added to it. At the October 29–31 meeting, then, the ISO subcommittee altered the ISO draft to meet the CCITT requirements, replacing the up-arrow and left-arrow with diacriticals, adding diacritical meanings to the apostrophe and quotation mark, and making the number sign a dual for the tilde.[2]

Yucca's free information site

Thus, ISO 646 was born and the ASCII standard updated to include the backtick and other symbols.[lower-alpha 4]

As surrogate of apostrophe or (opening) single quote

Some early typewriters and ASCII peripherals designed the backtick and apostrophe to be mirror images of each other.[3] This allowed them to be used as matching pairs of open and close quotes, and also as grave and acute accents, and allowed the apostrophe to be used as a prime. None of these were considered typographically correct.

The use of apostrophe for opening quotes, the need on some typewriters to overprint apostrophe and period to get an exclamation mark, and the lack of a mirrored double-quote character, tended to change the apostrophe to the modern "typewriter" design that is vertical, so this no longer works. Unicode now provides separate characters for opening and closing quotes.

Such style is sometimes used even nowadays; examples are: output generated by some UNIX console programs, rendering of man pages within some environments, technical documentation written long ago or written in old-school manner. However, as time goes on, such style is used less and less, and even institutions that traditionally were using that style are now abandoning it.[4][5]

Computing

Command-line interface languages

Many command-line interface languages and the scripting (programming) languages like Perl, PHP, Ruby and Julia (though see below) use pairs of backticks to indicate command substitution. A command substitution is the standard output from one command, into an embedded line of text within another command.[6][7] For example, using $ as the symbol representing a terminal prompt, the code line:

$ echo It is now `date`

on execution, produces the output:

It is now Wed Oct 25 18:29:01 GMT 2023

In Bash shell and Z shell, the use of backticks for command substitution is now largely deprecated in favor of the notation $(...), so that one of the examples above would be re-written:

$ echo It is now $(date)

The new syntax allows nesting, for example:

$ cd $(dirname $(type -P touch))

Markup languages

It is sometimes used in source code comments to indicate code, e.g.,

/* Use the `printf()` function. */

This is also the format the Markdown formatter uses to indicate code.[8] Some variations of Markdown support "fenced code blocks" that span multiple lines of code, starting (and ending) with three backticks in a row (```).[9]

  • TeX: The backtick character represents curly opening quotes. For example, ` is rendered as single opening curly quote () and `` is a double curly opening quote (). It also supplies the numeric ASCII value of an ASCII character wherever a number is expected.

Programming languages

  • BBC BASIC: The backtick character is valid at the beginning of or within a variable, structure, procedure or function name.
  • D and Go: The backtick surrounds a raw string literal.
  • F#: Surrounding an identifier with double backticks allows the use of identifiers that would not otherwise be allowed, such as keywords, or identifiers containing punctuation or spaces.
  • Haskell: Surrounding a function name by backticks makes it an infix operator.
  • JavaScript: ECMAScript 6 standard introduced a "backtick"[10] character which indicated a string or template literal. Its applications include (but are not limited to): string interpolation (substitution), embedded expressions, and multi-line strings. In the following example name and pet variable's values get substituted into the string enclosed by grave accent characters:
const name = "Mary", pet = "lamb"; // Set variables
let   temp = `${name} has a little ${pet}!`;
      console.log(temp);
      // => "Mary has a little lamb!";
  • Lisp macro systems: The backtick character (called quasiquote in Scheme) introduces a quoted expression in which comma-substitution may occur. It is identical to the plain quote, except that a nested expression prefixed with a comma is replaced with the value of that nested expression. If the nested expression happens to be a symbol (that is, a variable name in Lisp), the symbols' value is used. If the expression happens to be program code, the first value returned by that code is inserted at the respective location instead of the comma-prefixed code. This is roughly analogous to the Bourne shell's variable interpolation with $ inside double quotes.
  • Julia: Backticks make a command object, Cmd, that can be run, with run function, like run(`echo Hello world!`). You can interpolate Julia variables, but only indirectly shell environment variables.
  • m4: A backtick together with an apostrophe quotes strings (to suppress or defer macro expansion).
  • MySQL: A backtick in queries is a delimiter for column, table, and database identifiers.
  • OCaml: The backtick indicates polymorphic variants.
  • Pico: The backtick indicates comments in the programming language.
  • PowerShell: The backtick is used as the escape character. For example, a newline character is denoted `n. Most common programming languages use a backslash as the escape character (e.g., \n), but because Windows allows the backslash as a path separator, it is impractical for PowerShell to use backslash for a different purpose. Two backticks produce the ` character itself. For example, the nullable boolean of .NET is specified in PowerShell as [Nullable``1[System.Boolean]].
  • Python : Prior to version 3.0, backticks were a synonym for the repr() function, which converts its argument to a string suitable for a programmer to view. However, this feature was removed in Python 3.0. Backticks also appear extensively in the reStructuredText plain text markup language (implemented in the Python docutils package).
  • R: The backtick is used to surround non-syntactic variable names. This includes variable names containing special characters or reserved words, among others.[11]
  • Racket: The backtick or "Quasiquote" is used to begin creating lists.
  • Scala: An identifier may also be formed by an arbitrary string between backticks. The identifier then is composed of all characters excluding the backticks themselves.[12]
  • Tom: The backtick creates a new term or to calls an existing term.
  • Unlambda: The backtick character denotes function application.
  • Verilog HDL: The backtick is used at the beginning of compiler's directives.

Games

In many PC-based computer games in the US and UK, the ` key is used to open the console so the user can execute script commands via its CLI. This is true for games such as Factorio, Battlefield 3, Half-Life, Halo CE, Quake, Half-Life 2, Blockland, Soldier of Fortune II: Double Helix, Unreal, Counter-Strike, Crysis, Morrowind, Oblivion, Skyrim,[13] Fallout: New Vegas, Fallout 3, Fallout 4, RuneScape, and games based on the Quake engine or Source engine. While not necessarily the original progenitor of the console key concept, Quake is still widely associated with any usage of the ` key as a toggle for a drop-down console, often being referred to as the "Quake Key". In 2021, Windows Terminal introduced a "Quake Mode" which enables a global shortcut of ⊞ Win+` (with a predictable result).[14]

See also

Notes

  1. Upper case letters would require the character to be printed higher on the page
  2. In ISO/IEC 8859-1 ("ISO Latin 1") and subsequently in Unicode.
  3. With US keyboards, the same key produces the free-standing tilde ~ if shift is held down. On UK keyboards, ⇧ Shift+` produces the “logical not” symbol, ¬, unless reallocated.
  4. ISO 646 (and ASCII, which it includes) is a standard for 7-bit encoding, providing just 96 printable characters (and 32 control characters). This was insufficient to meet the needs of Western European languages and so the standard specifies certain code points that are available for national variation. The code point allocated to backtick is 0x60 (decimal 96) is one such. Consequently, code-point 0x60 was often reallocated in local character sets to a more useful character. For example, in the French ISO 646 standard, the character at this position is µ. Many older UK computers (such as the ZX Spectrum and BBC Micro) have the pound sign (£) symbol at character 0x60, although BS 4730 (the British ISO 646 variant) placed '£' at position 0x23 instead. With the arrival of 8-bit "extended ASCII", this issue was largely mitigated, though not fully resolved until Unicode was established.

References

  1. Kuhn, Markus. "Apostrophe and acute accent confusion". Department of Computer Science and Technology, University of Cambridge. This key is on German typewriters a non-spacing key (DIN 2137). It does not advance the cursor, but causes the next character to appear below the accent
  2. "Character histories: notes on some ASCII code positions".
  3. Kuhn, Markus. "ASCII and Unicode quotation marks". Department of Computer Science and Technology, University of Cambridge. Please do not use the ASCII grave accent as a left quotation mark
  4. "GNU Coding Standards: Quote Characters". GNU Coding Standards. Free Software Foundation. 19 February 2019. Retrieved 12 March 2019. In the C locale, the output of GNU programs should stick to plain ASCII for quotation characters in messages to users: preferably 0x22 (‘"’) or 0x27 (‘'’) for both opening and closing quotes. Although GNU programs traditionally used 0x60 (‘`’) for opening and 0x27 (‘'’) for closing quotes, nowadays quotes ‘`like this'’ are typically rendered asymmetrically, so quoting ‘"like this"’ or ‘'like this'’ typically looks better.
  5. Eggert, Paul (23 January 2012). "makeinfo should quote 'like this' instead of `like this'". bug-texinfo Archives. Retrieved 27 March 2018.
  6. "Shell expansion". tldp.org. Retrieved 27 March 2018.
  7. "An Introduction to the Z Shell – Command/Process Substitution". zsh.sourceforge.net. Retrieved 27 March 2018.
  8. "Daring Fireball: Markdown Syntax Documentation".
  9. "GitHub Flavored Markdown Spec". Archived from the original on 21 February 2022. Retrieved 23 February 2022.
  10. "Template literals (Template strings)". MDN Web Docs. Retrieved 22 May 2019.
  11. R Core Team, Quotes: Quotes, R Foundation for Statistical Computing.
  12. Odersky, Martin (24 May 2011), The Scala Language Specification Version 2.9
  13. "Skyrim:Console". UESPWiki. Retrieved 15 November 2019.
  14. Cinnamon, Kayla. "Windows Terminal Preview 1.9 Release". devblogs.microsoft.com. Retrieved 5 June 2023.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.