ComputerScientist
174 subscribers
14 photos
3 files
206 links
▜ The Inventor

Stuff that inspire you to create.

See also: ▙ @LitMind
Download Telegram
Blocks
- are lexical structures that allow many statements to be treated as one. A language that allows blocks and nested blocks, is called block-structured. Blocks are fundamental to #structured programming.

As scopes
Depending on the language, certain distinguished blocks may be treated as lexical scopes; otherwise, identifiers assigned in outer blocks are visible inside inner blocks, unless shadowed.

Syntax
• Free-form
Whitespace only delimits tokens and has no other significance
begin ... end: #ALGOL, #Pascal
{ ... }: #C, #Perl, #JS, #Nile
( keyword ... ): #Lisp

• Off-side rule
Indentation groups blocks of code
e.g. #Python, #Haskell, #Cobra, #CoffeeScript

Limitations
In some languages blocks do not fully support all declarations; for instance many C-derived languages do not permit nested functions.