SIGIL (COMPUTER PROGRAMMING)
In computer programming, a 'sigil' is a symbol attached to a variable name, showing the variable's datatype. The term was first applied to Perl usage by Philip Gwyn in 1999 to replace the more cumbersome "funny character in front of a variable name". The name is presumably based on the word meaning a magical symbol (see ''sigil (magic)'').
The use of sigils was popularized by the BASIC programming language. The best known example of a sigil in BASIC is the dollar sign (“
Larry Wall adopted shell scripting’s use of sigils for his popular scripting language Perl. However, as Perl is a weakly typed language, the sigils specify not fine-grained data types like strings and integers, but general categories such as scalars (using a prepended “
In various Unix-related contexts, such as shell scripting and Makefiles, the "
In the PHP language, which was partly inspired by Perl, “
In Ruby, ordinary variables lack sigils, but “
In Transact-SQL, “
In Fortran, all variables starting with the letters I, J, K, L, M and N are integers although Fortran refers to this as "implicit typing". (This is the source of the long tradition of using "i", "j", "k" etc as the loop indexes of "for loops" in many programming languages—few of which have implicit typing).
In mIRC script, identifiers have a $ sigil, while all variables have a % prefixed (regardless of local or global variables or data type). Binary variables are prefixed by a &.
Related to sigils is Hungarian notation, a convention for variable naming that specifies variable type by attaching certain alphabetic prefixes to the variable name. Unlike sigils, however, Hungarian notation provides no information to the compiler; as such, explicit types must be redundantly given for the variables and the prefixes are not enforced, making them more prone to omission and misuse.
★ Identifier
★ Source code
★ Token
★ Tokenizing
| Contents |
| Historical context |
| Language comparison |
| Hungarian notation |
| See also |
Historical context
The use of sigils was popularized by the BASIC programming language. The best known example of a sigil in BASIC is the dollar sign (“
$”) appended to the names of all strings. Many BASIC dialects use other sigils to denote integers and floating point numbers, and sometimes other types as well.Larry Wall adopted shell scripting’s use of sigils for his popular scripting language Perl. However, as Perl is a weakly typed language, the sigils specify not fine-grained data types like strings and integers, but general categories such as scalars (using a prepended “
$”), arrays (using a “@”), hashes (using a “%”), and subroutines (using a “&”). Perl 6 introduces secondary sigils, or 'twigils', which are used to indicate the scope of variables. Prominent examples of twigils in Perl 6 include “^”, used with self-declared formal parameters (“placeholder variables”), and “.”, used with object attribute accessors (i.e., instance variables).Language comparison
In various Unix-related contexts, such as shell scripting and Makefiles, the "
$" sigil was used to access the contents of a variable.In the PHP language, which was partly inspired by Perl, “
$” precedes any variable name. Names not prepended by this are considered constants.In Ruby, ordinary variables lack sigils, but “
$” is prefixed to global variables, “@” is prefixed to instance variables, and “@@” is prefixed to class variables (the second “@” cannot be considered a twigil, so “@@” is just a longer sigil).In Transact-SQL, “
@” precedes a local variable or parameter name. System variables (known as global variables) are distinguished by a “@@” prefix.In Fortran, all variables starting with the letters I, J, K, L, M and N are integers although Fortran refers to this as "implicit typing". (This is the source of the long tradition of using "i", "j", "k" etc as the loop indexes of "for loops" in many programming languages—few of which have implicit typing).
In mIRC script, identifiers have a $ sigil, while all variables have a % prefixed (regardless of local or global variables or data type). Binary variables are prefixed by a &.
Hungarian notation
Related to sigils is Hungarian notation, a convention for variable naming that specifies variable type by attaching certain alphabetic prefixes to the variable name. Unlike sigils, however, Hungarian notation provides no information to the compiler; as such, explicit types must be redundantly given for the variables and the prefixes are not enforced, making them more prone to omission and misuse.
See also
★ Identifier
★ Source code
★ Token
★ Tokenizing
This article provided by Wikipedia. To edit the contents of this article, click here for original source.
psst.. try this: add to faves

العربية
中国
Français
Deutsch
Ελληνική
हिन्दी
Italiano
日本語
Português
Русский
Español