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)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
R103 - Basic Ruby Language Elements [986] puts - opposite of chomp in Ruby - (2006-12-15)
[2287] Learning to program in Ruby - examples of the programming basics - (2009-07-15)
[2296] Variable scope - what is it, and how does it Ruby? - (2009-07-18)
[2613] Constants in Ruby - (2010-02-01)
[2617] Comparing floating point numbers - a word of caution and a solution - (2010-02-01)
[3278] Do I need to initialise variables - programming in C, C++, Perl, PHP, Python, Ruby or Java. - (2011-05-05)
[3758] Ruby - standard operators are overloaded. Perl - they are not - (2012-06-09)
[3917] BODMAS - the order a computer evaluates arithmetic expressions - (2012-11-09)
[4324] Learning to program - variables and constants - (2014-11-22)
[4369] Ruby - the second rung of learning the language - (2014-12-28)
[4504] Where does Ruby load modules from, and how to load from current directory - (2015-06-03)
P301 - Variables in Perl [975] Answering ALL the delegate's Perl questions - (2006-12-09)
[1581] What is an lvalue? (Perl, C) - (2008-03-18)
[1946] Variable Types in Perl - (2008-12-15)
[2241] Perl references - $$var and \$var notations - (2009-06-15)
[2374] Lead characters on Perl variable names - (2009-08-24)
[2877] Further more advanced Perl examples - (2010-07-19)
[2972] Some more advanced Perl examples from a recent course - (2010-09-27)
[3059] Object Orientation in an hour and other Perl Lectures - (2010-11-18)
[4398] Accessing variables across subroutine boundaries - Perl, Python, Java and Tcl - (2015-01-18)
[4608] Introspecion in Perl 6 - (2016-01-02)
P251 - Perl Review [2242] So what is this thing called Perl that I keep harping on about? - (2009-06-15)
[3007] Setting up a matrix of data (2D array) for processing in your program - (2010-10-21)
[3042] Least Common Ancestor - what is it, and a Least Common Ancestor algorithm implemented in Perl - (2010-11-11)
[3407] Perl - a quick reminder and revision. Test yourself! - (2011-08-26)
C234 - C and C based languages - Further C++ Object Oriented features [801] Simple polymorphism example - C++ - (2006-07-14)
[802] undefined reference to typeinfo - C++ error message - (2006-07-15)
[831] Comparison of Object Oriented Philosophy - Python, Java, C++, Perl - (2006-08-13)
[1159] It can take more that one plus one to get two. - (2007-04-22)
[1819] Calling base class constructors - (2008-10-03)
[2004] Variable Scope in C++ - (2009-01-22)
[2005] Variables and pointers and references - C and C++ - (2009-01-23)
[2576] What does const mean? C and C++ - (2010-01-15)
[2673] Multiple Inheritance in C++ - a complete example - (2010-03-12)
[2717] The Multiple Inheritance Conundrum, interfaces and mixins - (2010-04-11)
[2849] What are C++ references? Why use them? - (2010-07-02)
[3057] Lots of things to do with and within a C++ class - (2010-11-16)
[3069] Strings, Garbage Collection and Variable Scope in C++ - (2010-11-25)
[3124] C++ - putting the language elements together into a program - (2011-01-08)
[3238] Bradshaw, Ben and Bill. And some C and C++ pointers and references too. - (2011-04-09)
[3509] Operator Overloading, Exceptions, Pointers, References and Templates in C++ - new examples from our courses - (2011-11-06)
[3982] Using a vector within an object - C++ - (2013-01-19)
[4366] Changing what operators do on objects - a comparison across different programming languages - (2014-12-26)
[4377] Designing a base class and subclasses, and their extension, in C++ - (2015-01-01)
[4559] When do I use the this keyword in C++? - (2015-10-29)
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