Navigation
  • Home
  • Recent
  • Most Active
  • Popular
  • Blog
  • Credits
  • RSS
  •   Interaction
  • Register
  • Statistics
  •   Help
  • Suggestions
  • Contact Us
  • How to Edit
  • Help



  • [Edit]


    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.

        Curly bracket programming language
            History
            Statements and blocks
                Loops
                Conditional statements
                Exception handling
                Problems
            Languages

    top

    History
    Curly-bracket style goes way back before C. BCPL was the first language to use a curly bracket style, for outlining multi-statement function bodies. Ken Thompson gave the feature more glory in B. Because C was initially designed after B, C has retained the bracket style of B. Most languages that came after C (C++, Java, ECMAScript and its popular descendant JavaScript, C#, D, etc.) keep the style. Pico is a non-C descendant that also uses this style.

    Along with curly bracket style is the popular style of terminating a statement with a semicolon (;), which allows for languages that ignore whitespace. BCPL and Pico, do not have this rule. Thus a newline is used as a statement terminator in such languages. The Pico indent style is then used, as below (BCPL):

    LET FUNC foo(a) = VALOF


    top

    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.

    A popular way to work with curly braces is with the K&R style:

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

    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.

    top

    Loops
    In C, C++, C
      , and Java:
    while (boolean expression)


    do
    while (boolean expression);

    for (initialisation; termination condition; incrementing expr)


    top

    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)


    top

    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.

    top

    Problems
    Some 7 bit national ASCII sets redefine curly brackets to characters that make programs hardly readable on such designed terminals. For example, the YUSCII set used in Yugoslavia redefines '' is redefined to 'ċ'. To address this problem, ANSI C introduced trigraphs that can be used instead of such problematic characters. All trigraphs consist of two question marks (“??”) followed by a character that is not redefined in the national 7 bit ASCII character sets. The trigraphs for ‘’, respectively, are “??<” and “??>”.

    top

    Languages
      Ch - embeddable C/C++ interpreter
      ChucK - for audio programming
      Cilk - concurrent C for multithreaded parallel programming
      Coyote - C variant intended to lower the likelihood of some common errors, for example, buffer overflows
      D - C/C++ variant

     
    Search more:
     

       
    Source Privacy License Download Contact Us Atlas
    Scientus.org Dictionary (Yet Another Wiki) RC : 1.39
    MIT OpenCourseWare
    This article is licensed under the GNU Free Documentation License [copyleft]. It uses material from the Wikipedia article "Curly bracket programming language". link