Grave Accent - Technical Notes - Use in Programming

Use in Programming

Programmers have used the grave accent symbol as a separate character (i.e., not combined with any letter) for a number of tasks. In this role, it is known as a backquote or backtick.

When using TeX to typeset text, the backtick character is used as a syntax to represent curly opening quotes. For example, ` is rendered as single opening curly quote (‘) and `` is a double curly opening quote (“). It is also used for supplying the numeric ASCII value of an ASCII character wherever a number is expected.

Many of the Unix shells and the programming languages Perl, PHP, and Ruby use pairs of this character to indicate command substitution, that is, substitution of the standard output from one command into a line of text defining another command. For example, the code line:

echo It is now `date`

might result, after command substitution, in the command:

echo It is now Wed Dec 12 16:59:06 GMT 2012

which then on execution produces the output:

It is now Wed Dec 12 16:59:06 GMT 2012

In the Bash shell, the `...` syntax is not recommended by style guides (though it is not formally deprecated), and the alternate syntax $(...) is preferred because it is more readable, especially for nested expressions. The same is true of Z shell.

In Lisp macro systems, the backquote character (called quasiquote in Scheme) introduces a quoted expression in which comma-substitution may occur. It is identical to the plain quote, except that symbols prefixed with a comma will be replaced with those symbols' values as variables. This is roughly analogous to the Unix shell's variable interpolation with $ inside double quotes.

In m4, it is used together with an apostrophe to quote strings (to suppress or defer macro expansion).

In MySQL, it is used in queries as a column, table and database classifier.

In Pico, the backquote is used to indicate comments in the programming language.

In Haskell, surrounding a function name by backquotes allows it to be used as an infix operator.

In OCaml, the backquote is used to indicate polymorphic variants.

In Tom, the backquote is used to create a new term or to call an existing term.

In D and Go, the backquote is used to surround a raw string literal.

Windows PowerShell uses the backquote as the escape character. For example, a newline character is denoted `n. Most commonly used programming languages use a backslash as the escape character (e.g. \n) but because Windows allows the backslash as a path separator, it would have been impractical for PowerShell to use backslash for a different purpose. To get the ` character itself, two backticks are used. For example, the nullable boolean of .NET is specified in PowerShell as ].

Prior to Python 3.0, backticks were used as 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 are also used extensively in the reStructuredText plain text markup language (implemented in the Python docutils package).

In Verilog, the grave accent is used to define constants (e.g., after the line `define NUM 100, `NUM can be used as a synonym for 100). By contrast, the apostrophe is used in specifying sized constants (for example, 5'd10 is a 5-bit constant with the value 10). Accidental use of an apostrophe instead of a grave accent and vice versa is a source of frequent beginner mistakes in the language.

In Unlambda, the backquote character denotes function application.

In BBC BASIC, the backquote character is valid at the beginning of or within a variable, structure, procedure or function name.

Read more about this topic:  Grave Accent, Technical Notes

Famous quotes containing the word programming:

    If there is a price to pay for the privilege of spending the early years of child rearing in the driver’s seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.
    Melinda M. Marshall (20th century)