Stropping (syntax)

From Wikipedia, the free encyclopedia
  (Redirected from Stropping (programming))
Jump to: navigation, search

In computer language design, stropping is a method of explicitly marking letter sequences as having a special property such as being a keyword or certain type of variable or storage location.

Stropping allows the same letter sequence to be used both as a keyword and as an identifier, and simplifies parsing in that case. Most modern programming languages do not allow this ambiguity: keywords are reserved words and cannot be used as identifiers.

In languages such as Algol 60 and Algol 68, stropping was a method of representing typographical distinctions found in the publication language in the hardware language.

Contents

Syntaxes [edit]

A range of different syntaxes for stropping have been used:

  • Algol 60 commonly used only the convention of quotes around the word (e.g. 'BEGIN' or ‘BEGIN’).
  • Algol 68[1][2] in some implementations treat letter sequences prefixed by a single quote, ', as being keywords (e.g., 'BEGIN)[3]

In fact it was often the case that several stropping conventions might be in use within the one language:

  • Atlas Autocode had the choice of three: keywords could be underlined using backspace and overstrike on a Flexowriter keyboard, they could be introduced by a %percent %symbol, or they could be typed in UPPER CASE with no delimiting character (in which case all variables had to be in lower case).
  • ALGOL 68RS programs are allowed the use of several stropping variants, even within the one language processor.

Examples of different ALGOL 68 styles [edit]

Algol68 as typically published
¢ bold or underline typeface ¢
mode xint = int;
xint sum sq:=0;
for i while
  sum sq≠70×70
do
  sum sq+:=i↑2
od 
Quote stropping (like wikitext)
'pr' quote 'pr' 
'mode' 'xint' = 'int';
'xint' sum sq:=0;
'for' i 'while'
  sum sq≠70×70
'do'
  sum sq+:=i↑2
'od'
For a 7-bit character code compiler
.PR UPPER .PR
MODE XINT = INT;
XINT sum sq:=0;
FOR i WHILE
  sum sq/=70*70
DO
  sum sq+:=i**2
OD 
For a 6-bit character code compiler
.PR POINT .PR
.MODE .XINT = .INT;
.XINT SUM SQ:=0;
.FOR I .WHILE
  SUM SQ .NE 70*70
.DO
  SUM SQ .PLUSAB I .UP 2
.OD
Algol68 using res stropping (reserved word)
.PR RES .PR
mode .xint = int;
.xint sum sq:=0;
for i while
  sum sq≠70×70
do
  sum sq+:=i↑2
od 

Other languages [edit]

For various reasons Fortran 77 has these "logical" values and operators: .TRUE. .FALSE. .EQ. .NE. .LT. .LE. .GT. .GE. .EQV. .NEQV. .OR. .AND. .NOT. [1]

Most modern programming languages do not use stropping - although Ruby and Perl both use sigils to identify characteristics of variables/constants: Perl to designate the type of variable, Ruby to distinguish variables from constants and to indicate scope.

See also [edit]

References [edit]

  1. ^ http://www.fh-jena.de/~kleine/history/languages/Algol68-RR-HardwareRepresentation.pdf
  2. ^ van Wijngarten et al. (1976) Section 9.3
  3. ^ Lindsey and van der Meulen (1977) pp.348-349