The Open Directory Project.

Directory of Off-side Rule Resources

Home > Computers > Programming > Languages > Off-side Rule

This category involves one means by which different programming languages, within program code, control the scope of declarations, have blocks, how such start and end, and are: marked, formed, shown, expressed, indicated, denoted; their span. Some programming languages obey the off-side rule: blocks are shown by their indentation, the whitespace that precedes them. The term was invented and named by Peter J. Landin in "The Next 700 Programming Languages", CACM vol 9 pp 157-165, March 1966: "Any non-whitespace token to the left of the first such token on the previous line is taken to be the start of a new declaration." Off-side Rule language families: ISWIM, an abstract language that introduced the rule in 1966; ABC, Python; Miranda, Haskell, Curry; Occam; Pliant. Alternatives:

The main alternative is paired symbols or keywords. Most programming languages use this means to mark blocks.

C-syntax family: whitespace is ignored. Blocks are marked between curly braces { and }. Advantage: code can be reformatted and neatly indented, even automatically, with no fear of change to block structure. Disadvantage: human readers see indentation easily and quickly and often miss much formal meaning communicated in braces, unless they are very careful.

Pascal family: blocks shown by keywords, start with "begin", end with "end".

LISP family: doesn't differentiate statements from expressions, parentheses are enough.

POSIX shell family: blocks start after each control keyword and end with the keyword written backwards: "case" starts conditional statements, "esac" ends them.

Subcategories

Resources in This Category

Related Categories

 

Home > Computers > Programming > Languages > Off-side Rule

 


 

Thanks to DMOZ, which built a great web directory for nearly two decades and freely shared it with the web. About us