Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
Sigils - the characters on the start of variable names in Perl, Ruby and Fortran

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
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)

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)

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)

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)


Back to
Searching through all the files in or below a directory - Ruby, Tcl, Perl
Previous and next
or
Horse's mouth home
Forward to
Ruby at both extremes of your website
Some other Articles
Sundays - and over eating
Exceptions - a fail-safe way of trapping things that may go wrong
3 digit HTTP status codes - what are they, which are most common, which should be a concern?
Ruby at both extremes of your website
Sigils - the characters on the start of variable names in Perl, Ruby and Fortran
Searching through all the files in or below a directory - Ruby, Tcl, Perl
How many days to Christmas?
What is on the Melksham Agenda?
Automed web site testing scripted in Ruby using watir-webdriver
Our National Autograss Champion, from Melksham
4300 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/3430_Sig ... rtran.html • PAGE BUILT: Thu Sep 18 15:30:25 2014 • BUILD SYSTEM: WomanWithCat