Sigil for Variable Names
new crotchet: all function parameter names should start with φ and all local variable names should start with ξ .
Example in JavaScript:
function draw_rect (φx_coord, φy_coord, φwidth, φheight) { // returns a svg rect element var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); rect.setAttribute("x", φx_coord.toString()); rect.setAttribute("y", φy_coord.toString()); rect.setAttribute("width", φwidth.toString()); rect.setAttribute("height", φheight.toString()); return rect; }
〔see JavaScript Tutorial by Example〕
this is experimental. I'm going to see how it goes.
why do you want to do this?
I want to be able to distinguish function parameters easily from local variables. (and, ideally, also easily distinguish GLOBAL variables. And built-in vs user-defined. And, wish every identifier is unique.) 〔see Variable Naming: English Words Considered Harmful〕
note, the choice of the character takes some consideration. You want a char that is:
- Unicode letter. (such as Greek letter), because some languages do not allow identifier to start with a char that's not a Unicode letter. (For example, Python 2. Lexical analysis — Python v3.3.3 documentation#identifiers and JavaScript. For what's a Unicode letter, see: JS: Allowed Characters in Identifier)
- Widely recognized. (For example, Chinese char would not be appropriate.)
- Visually distinct from English alphabets, regardless of font.
- Lower case and upper case can be distinguished, and also both must be visually distinct from any lower case or upper case English alphabets. (For example, greek ε and its capital Ε would be bad.)
note: sigil is mostly popularly associated with perl. But it's also used in PHP and Ruby, as these 2 languages directly borrowed it from Perl. (perl borrowed it from unix shell.) 〔see Perl Tutorial〕 〔see PHP in 1 Hour〕 〔see Ruby Tutorial〕
The idea of sigil is however quite widespread. Many languages have special chars as starting or ending variable names to indicate special purpose, though, mostly as a convention only, not part of the language machinery.
For example:
- Python class names always start with CapitalLetter. This is by convention.
- OCaml variable must start with lower case.
- In many languages, by convention, variable start with _ means it's not used.
- In many languages, by convention, variable start with double _ means it's internal.
- Mathematica builtin names start with Capital case.
- Mathematica variables starting with
$
are predefined global special variables. (see: http://reference.wolfram.com/mathematica/tutorial/GlobalSystemInformation.html), since 1988.
the name sigil is coined by Philip Gwyn in 1999 to refer to perl's sigil, according to Wikipedia.
Programing Language Naming of Things
- Unicode Support in Programing Language Function Name and Operator
- Problems of Symbol Congestion in Computer Languages; ASCII Jam vs Unicode
- Semantic of Symbols: HTML Entities, Ampersand, Unicode
- Syntax Design: Use of Unicode Matching Brackets as Specialized Delimiters
- Syntax Semantics Design: Use of Unicode Ellipsis Symbol vs Dot Dot Dot
- URL Percent Encoding and Unicode
- Unicode Semantics: the Ɐ in Turn A Gundam