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:
“The quest for certainty blocks the search for meaning. Uncertainty is the very condition to impel man to unfold his powers.”
—Erich Fromm (19001980)
“Good blocks of oak it was I split,
As large around as the chopping block;
And every piece I squarely hit
Fell splinterless as a cloven rock.”
—Robert Frost (18741963)
“The Bible and the Church have been the greatest stumbling blocks in the way of womens emancipation.”
—Elizabeth Cady Stanton (18151902)