Jump to content

Caret

From Wikipedia, the free encyclopedia

^
Caret
InUnicodeU+005E^CIRCUMFLEX ACCENT(^)
Different from
Different fromU+2038CARET
U+02C6ˆMODIFIER LETTER CIRCUMFLEX ACCENT
U+028CʌLATIN SMALL LETTER TURNED V
U+2227LOGICAL AND
U+039BΛGREEK CAPITAL LETTER LAMDA
Related
See alsoU+FF3EFULLWIDTH CIRCUMFLEX ACCENT

Caretis the name used familiarly for thecharacter^(the circumflex and a circumflex accent) provided on mostQWERTYkeyboards by typing⇧ Shift+6.The symbol has a variety of uses in programming and mathematics. The name "caret" arose from its visual similarity to the originalproofreader's caret,a mark used inproofreadingto indicate where a punctuation mark, word, or phrase should be inserted into a document. The formalASCIIstandard (X3.64.1977) calls it a "circumflex".[1]

History[edit]

Typewriters[edit]

Typewriter with French (AZERTY) keyboard:à,è,é,çùhave dedicated keys; thecircumflexanddiaeresisaccents havedead keys

On typewriters designed for languages that routinely usediacritics(accent marks), there are two possible ways to type these: keys can be dedicated toprecomposed characters(with the diacritic included); alternatively adead keymechanism 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. The^symbol was originally provided in typewriters and computer printers so thatcircumflex accentscould be overprinted on letters (as inôorŵ).

Transposition into ISO/IEC 646 and ASCII[edit]

The incorporation of the circumflex symbol into ASCII is a consequence of this prior existence on typewriters: this symbol did not exist independently as atypeorhot-leadprinting character. The original1963 version of the ASCII standardused the code point x5E for anup-arrow.However, the 1965 ISO/IEC646 standard defined code point x5E as one of five available for national variation,[a]with the circumflex^diacritic as the default and the up-arrow as one of the alternative uses.[2]In 1967, the second revision of ASCII followed suit.[3]

Caret compared to lower-case circumflex accent

Overprinting to add an accent mark was not always supported well by printers, and was almost never possible on video terminals. Instead, precomposed characters were eventually created to show the accented letters.[b]The freestanding circumflex (which had come to be called a caret) quickly became reused for many other purposes, such as incomputer languagesand mathematical notation. As the mark did not need to fit above a letter any more, it became larger in appearance such that it can no longer be used to overprint an accent.[4][c]

InUnicode,it is encoded asU+005E^CIRCUMFLEX ACCENT;inHTML,it may be inserted with^.

This caret is not to be confused with other chevron-shaped characters, such as theturned vor thelogical AND,which may occasionally be called carets.[5][6]

Uses[edit]

Programming languages[edit]

The symbol^has many uses inprogramming languages,where it is typically called a caret. It can signifyexponentiation,the bitwiseXORoperator,string concatenation[citation needed],andcontrol charactersincaret notation,among other uses. Inregular expressions,the caret is used to match the beginning of a string or line; if it begins a character class, then the inverse of the class is to be matched.

ANSI Ccan transcribe the caret in the form of thetrigraph??',as the character was originally not available in all character sets and keyboards. C++additionally supports tokens likexor(for^) andxor_eq(for^=) to avoid the character altogether. RFC1345recommends that the character be transcribed asdigraph'>when required.[7]

Pascaluses the caret for declaring and dereferencingpointers. InSmalltalk,the caret is the method return statement. InC++/CLI,.NET reference types are accessed through a handle using theClassName^syntax. In Apple'sC extensionsfor Mac OS X and iOS, carets are used to createblocksand to denote block types. Gouses it as abitwise NOToperator.

Node.jsuses the caret inpackage.jsonfiles to signify dependency resolution behavior being used for each particular dependency. In the case of Node.js, a caret allows any kind of update, unless it is seen as a "major" update as defined bysemver.[8]

Surrogate symbol for superscript and exponentiation[edit]

Inmathematics,the caret can signifyexponentiation(e.g.3^5for35) where the usualsuperscriptis not readily usable (as on somegraphing calculators). It is also used to indicate a superscript inTeXtypesetting. AsIsaac Asimovdescribed it in his 1974 "Skewered!" essay (onSkewes's number), "I make the exponent a figure of normal size and it is as though it is being held up by a lever, and its added weight when its size grows bends the lever down."[9]

The use of the caret for exponentiation can be traced back toALGOL 60,[citation needed]which expressed the exponentiation operator as an upward-pointing arrow, intended to evoke the superscript notation common in mathematics. The upward-pointing arrow is now used to signifyhyperoperationsinKnuth's up-arrow notation.

Escape character[edit]

It is often seen incaret notationto show control characters: for instance,^Ameans the control character with value 1.

The Windows command-line interpreter (cmd.exe) uses the caret toescapereserved characters (most other shells use thebackslash). For example, to pass a 'less-than' sign as an argument to a program, one would type^<.

Upward-pointing arrow[edit]

Ininternet forums,onsocial networking sitessuch as Facebook, or inonline chats,one or more carets may be used beneath the text of another post, representing an upward-pointing arrow to that post;[10]in addition to the arrow usage, it can also mean that the user who posted the ^ agrees with the above post. Multiple carets may be used to indicate that the comment is replying to, or relating to, the post above that correlates with the number of carets used, or to "underscore" the correct portion of the previous post, or simply for emphasis.

A similar use has been adopted by programming languagecompilers,such as the Java compiler, to point out where acompilation errorhas occurred.[citation needed]The compiler prints out the faulty line of code and uses a single caret on the next line, padded by spaces, to give a visual indication of the error location.

See also[edit]

Notes[edit]

  1. ^ISO646 (and ASCII, which it includes) is a standard for 7-bit encoding, providing just 96 printable characters (and 32control characters). This was insufficient to meet the needs of Western European languages and so the standard specifies certaincode pointsthat are available for national variation.
  2. ^For instance inISO Latin-1.
  3. ^Its actual shape, positioning and relative dimensions vary by font.

References[edit]

  1. ^"American National Standard for Information Interchange"(PDF).National Institute for Standards. 1977.(facsimile, not machine readable)
  2. ^"Character histories: notes on some ASCII code positions (5E)".
  3. ^Tom Jennings."ASCII: American Standard Code for Information Infiltration".Archived fromthe originalon 21 August 2014.Retrieved14 September2010.
  4. ^Jukka K. Korpela (18 January 2010)."Kirjainten tarinoita"(PDF)(in Finnish). pp. 132–133.Retrieved14 September2010.
  5. ^Unicode (1991–2012)."IPA Extensions"(PDF).Retrieved20 August2012.
  6. ^Eric W. Weisstein."Caret".MathWorld.Wolfram.Retrieved20 August2012.
  7. ^Simonsen, Keld (June 1992)."RFC 1345 – Character Mnemonics and Character Sets".Internet Engineering Task Force.Retrieved7 March2022.
  8. ^"Caret ranges in node.js".Archived fromthe originalon 3 December 2016.Retrieved1 October2019.
  9. ^Isaac Asimov(1974), "Skewered",Of Matters Great and Small,Doubleday,ISBN978-0385022255
  10. ^"What is Caret?".Computer Hope.Retrieved14 August2012.