Blocks
A block is a notation for a group of two or more statements, expressions or other units of code that are related in such a way as to comprise a whole.
Braces (aka Curly brackets) { ... }:
- Curly bracket programming languages: C, C++, Objective-C, Go, Java, JavaScript, ECMAScript, C#, D, Perl, PHP (
for&looploops, or pass a block as argument), Scala, S-Lang, Windows PowerShell, Haskell (in do-notation)
Parentheses ( ... )
- OCaml, Standard ML
Brackets
- Smalltalk (blocks are first class objects. aka closures)
begin ... end:
- Ada, ALGOL, Pascal, Ruby (
for,do/while&do/untilloops), OCaml, Simula, Erlang.
do ... done:
- Visual Basic, Fortran, TUTOR (with mandatory indenting of block body), Visual Prolog
do ... end
- Lua, Ruby (pass blocks as arguments,
forloop)
X ... end (e.g. if ... end):
- Bash (
for&whileloops), Ruby (if,while,until,def,class,modulestatements), OCaml (for&whileloops), MATLAB (if&switchconditionals,for&whileloops,tryclause,package,classdef,properties,methods,events, &functionblocks), Lua (then/else&function)
(begin ...):
- Scheme
(progn ...):
- Lisp
(do ...):
- Clojure
Indentation
- Off-side rule languages: Cobra, Haskell (in do-notation when braces are omitted), occam, Python
Others
- Bash, sh, and ksh:
if...fi,do...done,case...esac; - ALGOL 68:
begin...end,(...),if...fi,do...od - Lua:
repeat...until - COBOL:
IF...END-IF,PERFORM...END-PERFORM
Read more about this topic: Comparison Of Programming Languages (syntax)
Famous quotes containing the word blocks:
“He has given me six hundred street signs.
The time I was dancing he built a museum.
He built ten blocks when I moved on the bed.
He constructed an overpass when I left.”
—Anne Sexton (19281974)
“The vast silence of Buddha overtakes
and overrules the oncoming roar
of tragic life that fills alleys and avenues;
it blocks the way of pedicabs, police, convoys.”
—Denise Levertov (b. 1923)
“In any case, raw aggression is thought to be the peculiar province of men, as nurturing is the peculiar province of women.... The psychologist Erik Erikson discovered that, while little girls playing with blocks generally create pleasant interior spaces and attractive entrances, little boys are inclined to pile up the blocks as high as they can and then watch them fall down: the contemplation of ruins, Erikson observes, is a masculine specialty.”
—Joyce Carol Oates (b. 1938)