FACTOID # 18: Sick of crowds? Move to Greenland! Greenlanders have 38 square kilometres of land per person.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Code block

In computer programming, a statement block (or code block) is a section of code which is grouped together, much like a paragraph; such blocks consist of one, or more, statements. Statement blocks help make code more readable by breaking up programs into logical work units. The output from the process of computer programming (often shortened to programming or coding) is source code written in a programming language. ... Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. ... A pilcrow is used to indicate a paragraph. ... A statement is the minimal unit of structuring in imperative programming languages. ...


In C, C++, Java and some other languages, statement blocks are enclosed by braces {}. In Ada, Pascal, and some other languages, blocks are denoted by "begin" and "end" statements. In Python they are indicated by indentation (the Off-side rule). Unlike paragraphs, statement blocks can be nested; that is, with one block inside another. Blocks often define the scope of the identifiers used within. C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... C++ (IPA pronounciation: ) is a general-purpose, high-level programming language with low-level facilities. ... Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. ... Various brackets in Arial // In writing Brackets are punctuation marks, used in pairs to set apart or interject text within other text. ... Ada is a structured, statically typed imperative computer programming language designed by a team led by Jean Ichbiah of CII Honeywell Bull during 1977–1983. ... Pascal is an imperative computer programming language, developed in 1970 by Niklaus Wirth as a language particularly suitable for structured programming. ... Python is a programming language created by Guido van Rossum in 1990. ... A computer programming language is said to adhere to the off-side rule if in it the scope of declarations (a block) is expressed by their indentation, i. ... In computer programming in general, a scope is an enclosing context. ...


Blocks often have subtle but important differences in semantics. In languages in the C tradition, they define identifier scope. In C++ they can be used to define object lifetime (creation and destruction). In some languages (such as Pico) they are merely used for grouping expressions without notions of variable scope. In languages such as Smalltalk, blocks are objects in their own right, extended with a reference to their environment of definition, i.e. closures. Pico is a programming language developed at the PROG lab at the Dutch-speaking Free University of Brussels (Vrije Universiteit Brussel, VUB). ... Smalltalk is an object-oriented, dynamically typed, reflective programming language. ... In programming languages, a closure is a function that refers to free variables in its lexical context. ...

Contents

A typical statement block

 int main() { return 0; } 

A nested statement block

 int main() { int x=1; if (x == 1) { x++; } return 0; } 

Other formats

Java programmers typically use a slightly different convention for placing the braces. The opening brace is on the same line as the method declaration:

 int main() { return 0; } int main() { int x=1; if (x == 1) { x++; } return 0; } 

Visual Basic requires an explicit End statement, as follows:

 If x > 0 Then y = y + x End If For i = 1 To 10 DoSomething(i) Next ' or Next i 

SQL Server and some other languages use Begin ... End blocks

 IF y IS NOT NULL BEGIN SELECT * FROM employee WHERE name = y END 

See Also


  Results from FactBites:
 
Whitepaper: Seven Pillars of Pretty Code (1142 words)
Engineering such code requires a certain amount of artifice to transform otherwise working code into working, readable code, making the extra step to leave visual cues for the user, not the compiler.
This practice is best used in conjunction with "Disentangle Code Blocks:" a separated code block, composed of a pattern of lines with a single purpose, is a simple entity for the reader to grasp.
Real code of course requires substantial subblocks, necessarily indented, and these subblock will then have their own indentation battles to be fought.
ReSharper for Visual Studio .NET 2003 :: Code Assistance (688 words)
Context actions are intended for small code transformations that you may want to perform in a certain context.
In the same circumstances, pressing Ctrl + Shift + / inserts the opening block comment /* and the closing block comment */ strings immediately before and immediately after the caret's position or removes them if the caret is positioned inside the commented code block.
Extend Selection feature allows the user to successively select expanding blocks of code so that you may easily select any expression in the code by placing the caret somewhere inside it and pressing Ctrl + W a few times (see the figure).
  More results at FactBites »


 
 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms, 1022, m