Content-Type: text/shitpost


Subject: Sigils in Perl and PILOT
Path: you​!your-host​!walldrug​!prime-radiant​!computer​!glados​!extro​!forbin​!brain-in-a-vat​!berserker​!plovergw​!ploverhub​!shitpost​!mjd
Date: 2018-04-02T18:05:38
Newsgroup: comp.protocols.tcp-ip.sigils
Message-ID: <4c668a03140b034f@shitpost.plover.com>
Content-Type: text/shitpost

Perl notoriously prefixes variable names with symbols $, @, %, and * to indicate certain typing information. For example, $item is a scalar variable containing a single number or string, and @item is an array variable containing a numerically-indexed sequence of scalar values.

The most significant antecedent of which I was aware was PDP-11 BASIC-PLUS, which had three variable namespaces. The default variables could store a numeric value. Variables with names suffixed with $ could store strings, and those suffixed with % could store integers. BASIC-PLUS has been cited by Larry Wall as one of Perl's (many) inspirations. Its $ sigil was carried forward into the extremely influential Microsoft BASIC interpreters.

No ALGOL-derived language uses sigils, as far as I know.

(Unix shell languages use $, but not as a sigil. I mention this to save people the effort of emailing me. Variable names are un-sigilated. The $ indicates that the value of the variable is being retrieved. SNOBOL 4 does something similar.)

Today I learned about a forerunner that is much more Perl-like than the others: the PILOT language. String variables have names beginning with $; numeric variables have names beginning with #. Program labels begin with *. As in Perl, unprefixed identifiers are taken as literal strings. Wikipedia has a list of sigil-like language features#Historical_context) but it doesn't mention PILOT.

One could take a chronological chart of computer languages and draw a line down it that marked the switch from ad-hoc parsers to recursive parsers generated by parser-generating tools. It wouldn't be a straight line, but it wouldn't be excessively wiggly either. PILOT is very definitely on the left side of this line.

By the way, this use of the word “sigil” was coined in 1999 by Philip Gwyn, and caught on immediately. Prior to this, the Perl documentation had used the term “funny character”.