Lesson 4 of 81960–today7 min
Functions and scope
The report on ALGOL 60, edited by Peter Naur and written by a committee of European and American computer scientists, introduced the block: a stretch of code between begin and end that could declare its own variables, invisible from outside. Procedures were blocks with parameters.
ALGOL itself saw little commercial use, but the idea that a name belongs to the region of text where it is declared, called lexical scope, passed to Pascal, C, Java, JavaScript and Python. Every time a local variable vanishes at the end of a function, you are using a design from 1960.
The rest of this lesson is part of Pro
Create a free account to read the first lesson of every path, and go Pro for the rest.
Sources
- Revised Report on the Algorithmic Language ALGOL 60 — masswerk.at (transcription of the CACM report)
- Execution model: naming and binding — Python documentation
- Defining Functions — Python documentation