Opentopia Directory Encyclopedia Tools

Curly bracket programming language

Encyclopedia : C : CU : CUR : Curly bracket programming language


Curly brace or bracket programming languages are those which use balanced brackets (, also known as "brace brackets" or simply "braces") to make blocks in their syntax or formal grammar, mainly due to being C-influenced.

Statements and blocks

The name derives from the common syntax of the languages, where blocks of statements are enclosed in curly brackets. For example (using BSD/Allman indent style, one of many stylistic ways to format a program):

for (int i = 0; i < 10; i++)

Languages in this family are sometimes referred to as C-style, because they tend to have syntax that is strongly influenced by C syntax. 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.

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++)
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 (in Ada, Pascal, REXX, and Visual Basic), the Off-side rule of indentation (in Python), or other symbols such as parentheses (in Lisp). These ways are not necessarily exclusive: whereas indentation is the default in Haskell, curly brackets can be used when desired.

Loops

In C, C++, C#, and Java:
while (boolean expression) 
do  while (boolean expression);
for (initialisation; termination condition; incrementing expr) 

Conditional statements

In C, C++, C#, and Java:
if (boolean expression)

if (boolean expression)

else

if (boolean expression)

else if (boolean expression)

...
else

switch (integer expression)

Exception handling

In C++, C# and Java:
try

catch (exception type)

catch (exception type)

finally

Objective-C has the same syntax starting with gcc 3.3 and Apple Mac OS X 10.3 , but with an at sign in front of the keywords (@try, @catch, @finally).

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.

Problems

Some 7 bit national ASCII sets redefine curly brackets to characters that make programs hardly readable on such designed terminals. For example, YUSCII set used in Yugoslavia redefines '' is redefined to ċ

Languages

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: