FACTOID # 146: About one-quarter of all nations drive on the left-hand-side of the road. Most of them are former British colonies.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Curly brace family

This article describes the syntax of programming languages.

Contents

Comment

See comment


Statements and blocks

The curly brace family of programming languages includes C, C++, D, Java, AWK, Perl, PHP, C#, Pico programming language and others. The name derives from the common syntax of the languages, where blocks of statements are enclosed in curly braces. For example (using BSD/Allman indent style, one of many stylistic ways to format a program):

 for (int i = 0; i < 10; i++) { printf("%d", i); doTask(i); } 

Languages in this family are sometimes referred to as C-style, because they tend to have syntax that is strongly influenced by C's syntax. Beside the curly braces, they often inherit other syntactic features, such as using the semicolon as a statement terminator (not as a separator), and the three-part "for" statement syntax as shown above.


Generally, these languages are also considered "free-form languages", meaning that the compiler considers all whitespace to be the same as one blank space, much like HTML. Considering that, the above code could be written:

 for(int i=0;i<10;i++){printf("%d",i);doTask(i);} 

but this is not recommended, as it becomes nearly impossible for a person to read after the program grows beyond a few statements.


There are many other ways to identify statement blocks, such as ending keywords that may match beginning keywords (see Visual Basic, Pascal, Ada, and REXX), indentation (see Python), or other symbols such as parentheses (see LISP).


Loops

In Java, C and C++

 while (Boolean expression) { statement(s) } 
 do { statement(s) } while (Boolean expression); 
 for (initialisation ; termination condition ; incrementing expr) { statement(s) } 

Conditional statements

In Java, C and C++

 if (Boolean expression) { statement(s) } 
 if (Boolean expression) { statement(s) } else { statement(s) } 
 switch (integer expression) { case constant integer expr: statement(s) break; ... default: statement(s) break; } 

In Ruby,

 if expression then statement(s) end 

Exception handling

In Java:

 try { statement(s) } catch (exception type) { statement(s) } catch (exception type) { statement(s) } finally { statement(s) } 

C++ does not have finally, but otherwise looks similar. C has nothing like this, though some compilers vendors added the keywords __try and __finally to their implementation.


  Results from FactBites:
 
Brace@Everything2.com (573 words)
It may act as a tie, or as a strut, and serves to prevent distortion of the structure, and transverse strains in its members.
A boiler brace is a diagonal stay, connecting the head with the shell.
To move around by means of braces; as, to brace the yards.
Curly bracket programming language - Wikipedia, the free encyclopedia (671 words)
Curly brace or bracket programming languages are those which use balanced brackets ({ and }, also known as "brace brackets" or simply "braces") to make blocks in their syntax or formal grammar, mainly due to being C-influenced.
The name derives from the common syntax of the languages, where blocks of statements are enclosed in curly brackets.
Beside the curly brackets, they often inherit other syntactic features, such as using the semicolon as a statement terminator (not as a separator), and the three-part "for" statement syntax as shown above.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

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.