A sigil (from Latin sigillum "seal") is a symbol created for a specific magical purpose. A sigil is usually made up of a complex combination of several specific symbols or geometric figures, each with a specific meaning or intent. In computer programming, a sigil is a special symbol attached to a variable name, showing the variable's datatype or scope. Philip Gwyn, in 1999 adopted the term "to mean the funny character at the front of a Perl variable" and the term is applicable to Ruby too.
Ruby - everything is an object, the sigil defines the scope;
@abc Object variable. There's an @abc within each object in a class
$abc Global variable. Shared between methods / functions without being passed
@@abc Class variable. There's only one @@abc in a class, shared between all objects in the class
abc Local variable within current function / method / other similar closure
Abc Constant. Once set, it's read only
:abc Not really a variable either. An efficient unchanging piece of text.
Perl - definition is data type. Scope controlled with presence (or absence) of keywords
my or
our
$abc Scalar. Integer, float, string, reference or regular expression
@abc A list of scalars. Members are numbered upward from 0, so an
ordered collection
%abc A hash of scalars. Members are keyed by any scalar, often a string. An
unordered collection
abc A file handle
&abc A piece of code. A sub
*abc A Typeglob - a joint name for one of each of the abpve.
Rather than special characters,
Fortran used specific start letters for its variable names to represent interegers (start letter I J K L M and N) and reals (A to H and O to Z). An IMPLICIT statement was added at Fortran 77
Hungarian notation is where a variable name starts with a group of letters which are mnemonics for the type or purpose of that variable. That's followed by whatever name the programmer has chosen. So Fortran is an example where Hungarian notation is built into the language.
Hungarian notation is also often used as a convention (rather than a rule) in languages such as C and C++. It helps the coder who's revisiting the program for maintainance purposes to see what's what at a later date without having to scroll all the way back to the top of a piece of code.
[example]:
int weight = 96;
int *pWeight = &weight;
int &rWeight = weight; (written 2011-09-10)
2d6b
Associated topics are indexed under
C234 - C and C based languages - Further C++ Object Oriented features [3982] Using a vector within an object - C++ - (2013-01-19)
[3509] Operator Overloading, Exceptions, Pointers, References and Templates in C++ - new examples from our courses - (2011-11-06)
[3238] Bradshaw, Ben and Bill. And some C and C++ pointers and references too. - (2011-04-09)
[3124] C++ - putting the language elements together into a program - (2011-01-08)
[3069] Strings, Garbage Collection and Variable Scope in C++ - (2010-11-25)
[3057] Lots of things to do with and within a C++ class - (2010-11-16)
[2849] What are C++ references? Why use them? - (2010-07-02)
[2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
[2673] Multiple Inheritance in C++ - a complete example - (2010-03-12)
[2576] What does const mean? C and C++ - (2010-01-15)
[2005] Variables and pointers and references - C and C++ - (2009-01-23)
[2004] Variable Scope in C++ - (2009-01-22)
[1819] Calling base class constructors - (2008-10-03)
[1159] It can take more that one plus one to get two. - (2007-04-22)
[831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
[802] undefined reference to typeinfo - C++ error message - (2006-07-15)
[801] Simple polymorphism example - C++ - (2006-07-14)
P301 - Variables in Perl [3059] Object Orientation in an hour and other Perl Lectures - (2010-11-18)
[2972] Some more advanced Perl examples from a recent course - (2010-09-27)
[2877] Further more advanced Perl examples - (2010-07-19)
[2374] Lead characters on Perl variable names - (2009-08-24)
[2241] Perl references - $$var and \$var notations - (2009-06-15)
[1946] Variable Types in Perl - (2008-12-15)
[1581] What is an lvalue? (Perl, C) - (2008-03-18)
[975] Answering ALL the delegate's Perl questions - (2006-12-09)
P251 - Perl Review [3407] Perl - a quick reminder and revision. Test yourself! - (2011-08-26)
[3042] Least Common Ancestor - what is it, and a Least Common Ancestor algorithm implemented in Perl - (2010-11-11)
[3007] Setting up a matrix of data (2D array) for processing in your program - (2010-10-21)
[2242] So what is this thing called Perl that I keep harping on about? - (2009-06-15)
R103 - Basic Ruby Language Elements [3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
[3758] Ruby - standard operators are overloaded. Perl - they are not - (2012-06-09)
[3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
[2617] Comparing floating point numbers - a word of caution and a solution - (2010-02-01)
[2613] Constants in Ruby - (2010-02-01)
[2296] Variable scope - what is it, and how does it Ruby? - (2009-07-18)
[2287] Learning to program in Ruby - examples of the programming basics - (2009-07-15)
[986] puts - opposite of chomp in Ruby - (2006-12-15)
Some other Articles
Sundays - and over eatingExceptions - a fail-safe way of trapping things that may go wrong3 digit HTTP status codes - what are they, which are most common, which should be a concern?Ruby at both extremes of your websiteSigils - the characters on the start of variable names in Perl, Ruby and FortranSearching through all the files in or below a directory - Ruby, Tcl, PerlHow many days to Christmas?What is on the Melksham Agenda?Automed web site testing scripted in Ruby using watir-webdriverOur National Autograss Champion, from Melksham